SBits and UBits Data Types

Holds integer values of a specified width in bits.


field_name As { SBits | UBits } [ value_type ] ( width )


A name for a field in a structure.
Optional value type between brackets ([ ]). Examples include Int8, UInt16, Int32, UInt64, and Int128. If supplied, width cannot be more than the size of value_type in bits.
An integer literal for the number of bits.


SBits is short for “signed bits” and UBits is short for “unsigned bits”.

You can declare elements of SBits and UBits only in a structure (Struct).
Default value
If you declare an element with SBits or UBits and do not initialize it, its default value is zero (0).

If you use the negation operator (-) on an unsigned type, ViviFire gives a warning that this operation is usually an error.

If you subtract a larger number from a smaller number, you find the result as follows:

number Mod UBits(width).Max + 1
Automatic conversions
SBits and UBits widen to UInt64, UInt128, Real32, Real64, or Real128 without risk of overflow.
Type characters
SBits and UBits have no type characters.

Shared methods and properties

SBits(width).Max As Int32
UBits(width).Max As UInt32
Returns the maximum value.
SBits(width).Min As Int32
UBits(width).Min As UInt32
Returns the minimum value. For UBits, this is always zero (0).
SBits(width).Size As Int32
UBits(width).Size As Int32
Returns the number of available bytes.


Struct foobar
    foo As SBits[UInt8](4)
    bar As UBits[UInt8](4)
End Struct

See also