This project is read-only.
Basic type and printf

Category:
Arithmetic
Description: Basic type and printf
Code:
let TypeAndPrintf() = 
let int = 42
let string = "This is a string"
let char = 'c'
let bool = true
let bytearray = "This is a byte string"B
let hexint = 0x34
let octalint = 0o42
let binaryinteger = 0b101010
let signedbyte = 68y
let unsignedbyte = 102uy
let smallint = 16s
let smalluint = 16us
let integer = 345l
let usignedint = 345ul
let nativeint = 765n
let unsignednativeint = 765un
let long = 12345678912345789L
let unsignedlong = 12345678912345UL
let float32 = 42.8F
let float = 42.8

printfn "int = %d or %A" int int
printfn "string = %s or %A" string string
printfn "char = %c or %A" char char
printfn "bool = %b or %A" bool bool
printfn "bytearray = %A" bytearray
printfn "hex int = %x or %A" hexint hexint
printfn "HEX INT = %X or %A" hexint hexint
printfn "oct int = %o or %A" octalint octalint
printfn "bin int = %d or %A" binaryinteger binaryinteger
printfn "signed byte = %A" signedbyte
printfn "unsigned byte = %A" unsignedbyte
printfn "small int = %A" smallint
printfn "small uint = %A" smalluint
printfn "int = %i or %A" integer integer
printfn "uint = %i or %A" usignedint usignedint
printfn "native int = %A" nativeint
printfn "unsigned native int = %A" unsignednativeint
printfn "long = %d or %A" long long
printfn "unsigned long = %A" unsignedlong
printfn "float = %f or %A" float32 float32
printfn "double = %f or %A" float float
//--------------------------------------------------------

Execution Result:
int = 42 or 42
string = This is a string or "This is a string"
char = c or 'c'
bool = true or true
bytearray = [|84uy; 104uy; 105uy; 115uy; 32uy; 105uy; 115uy; 32uy; 97uy; 32uy; 98uy; 121uy;
116uy; 101uy; 32uy; 115uy; 116uy; 114uy; 105uy; 110uy; 103uy|]
hex int = 34 or 52
HEX INT = 34 or 52
oct int = 42 or 34
bin int = 42 or 42
signed byte = 68y
unsigned byte = 102uy
small int = 16s
small uint = 16us
int = 345 or 345
uint = 345 or 345u
native int = 765n
unsigned native int = 765un
long = 12345678912345789 or 12345678912345789L
unsigned long = 12345678912345UL
float = 42.800000 or 42.7999992f
double = 42.800000 or 42.8

Last edited Sep 14, 2011 at 3:23 AM by ttliu2000, version 1

Comments

No comments yet.