let dayOfBirth : uint32 = 8u let monthOfBirth : uint32 = 11u let yearOfBirth : uint32 = 1996u
To include an unsigned integer in the call to sprintf, use %u in the placeholder. Here is an example:
open System open System.Windows.Forms let exercise = new Form() exercise.Text <- "Exercise" exercise.Width <- 140 exercise.Height <- 80 let lblDistance = new Label() lblDistance.Left <- 28 lblDistance.Top <- 18 lblDistance.Width <- 228 let distance : uint32 = 372u let strDistance = sprintf "Distance: %u" distance lblDistance.Text <- strDistance exercise.Controls.Add(lblDistance) Application.Run(exercise)
This would produce:
To convert a number to an unsigned integer, call the uint32() function.
An unsigned short integer is a relatively small positive number between 0 and 65535. When declaring a variable for such a value, when initializing it, add a us suffix to its value. Here are examples:
let numberOfTracks = 16us let musicCategory = 2us
If you want to indicate the data type of the variable, use uint16. Here are examples:
let numberOfTracks:uint16 = 16us; let musicCategory:uint16 = 2us;
To convert a value to an unsigned short integer, call the uint16() function.
An unsigned long integer is a positive number ranging from 0 to very large. To support those types of values, the F# language provides the uint64 data type. When initializing the variable, add UL to its value.