Home

F# Type: Byte

   

Description

A byte is a number whose value can range from -128 t0 +127. To initialize a signed byte variable, add y to its value. Here is an example:

let roomTemperature = -88y;

To represent the value of a signed byte variable, use %d.

Instead of a decimal number, you can also initialize an integral variable with a hexadecimal value. When doing this, make sure the decimal equivalent is less than 255. Here is an example:

let number = 0xFE

To convert a number to byte, call the byte function. Here is an example:

let number = -85248;
let result = byte number;

A Signed Byte

A signed byte is a small number that can be negative or positive, rangin between -128 and 127.  To declare a variable for that kind of value, you can apply the sbyte type. Here is an example:

let roomTemperature : sbyte = -88y;

An Unsigned Byte

An unsigned byte is a small number between 0 and 255. When declaring a variable that would hold such a small natural number and when initialyzing it, add uy to the right of the value. Here is an example:

let age = 14uy

Make sure you don't use a value that is higher than 255 oterwise, you would receive an error.

     
 

Home Copyright © 2009-2015, FunctionX Home