Fsharp: Number

By Xah Lee. Date: .

Default Integer Number Type

By default, number input without decimal point is signed 32-bit integer. -2147483648 to 2147483648, inclusive.

printfn "%A" -2147483648l
// -2147483648
printfn "%O" (-2147483648l.GetType())
// System.Int32

Default Float Number Type

By default, number input with decimal point is signed 64-bit.

// type: float double
printfn "%A" 8.25
printfn "%O" (8.25.GetType())
// System.Double

printfn "%A" 2.3E+32
printfn "%A" 2.3e+32
printfn "%A" 2.3e-32

printfn "%A" infinity
printfn "%A" -infinity

Number separator

let xx = 67_758_773
printfn "%d" xx
// 67758773

Binary, octal, hexadecimal

let xdecimal  = 255
printfn "%d" xdecimal
// 255
let xbinary = 0b11111111
printfn "%d" xbinary
// 255
let xoct = 0o77
printfn "%d" xoct
// 63
let xhexadecimal = 0xff
printfn "%d" xhexadecimal
// 255