SBits and UBits Data Types

Holds integer values of a specified width in bits.


field_name As { SBits | UBits } ( width )


A name for a field in a structure.
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, then its default value is zero (0).

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

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

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

Shared methods and properties

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


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

See also