Fsharp: Number

By Xah Lee. Date: . Last updated: .

Default Integer Number Type

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

printfn "%i" 34
// 34

printfn "%O" ((34).GetType())
// System.Int32

Default Float Number Type

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

printfn "%f" 8.25
// 8.25

printfn "%O" ((8.25).GetType())
// System.Double

Number separator

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

Binary, octal, hexadecimal

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