Skip to content

Numbers of Other Sizes

Claude edited this page Oct 27, 2026 · 1 revision

Numbers of other sizes

The originals have two kinds of numbers: a 32-bit integer (Int) and a 32-bit real (Float). BlitzLLVM also has the integers Byte, UByte, Short, UShort, UInt, Long and ULong (8, 16, 32 and 64 bits, with and without a sign), and the reals Half and Double. A variable gets one of these types with name:Type, and a function of the same name as the type converts to it (Byte(x), UInt(x), Double(x) and so on, next to the Int, Float and Str that the originals have). A program that never uses them behaves exactly as before.

  • Calculations promote to at least 32 bits: a Byte plus a Byte is an Int, and the result only goes back to 8 bits when it is assigned to a Byte again. Unsigned wins when the widths are equal, so a UInt and an Int make a UInt, and a Long and a ULong make a ULong. Reals promote to at least a Float.
  • Converting a whole number to a smaller type keeps its lowest bits (Byte(200) is -56, UByte(-1) is 255), and to a larger type keeps its value, extending the sign of a signed type and filling with 0 for an unsigned one. The Sat versions (SatByte, SatUByte, SatShort, SatUShort, SatInt, SatUInt, SatLong, SatULong) stop at the smallest and largest number of the type instead.
  • Converting a real to a whole number rounds to the nearest whole number (halves go to the even one, as Int does in the original) and stops at the smallest and largest number of the type, with a real that is not a number becoming 0. Int(10000000000.0) is 2147483647.
  • Abs and Sgn see an unsigned number as never negative, and Min, Max, comparisons, division and Mod of an unsigned number are done without a sign, and Shr fills with 0 for every type.
  • Sqr, Sin, Cos, Tan, ASin, ACos, ATan, ATan2, Floor, Ceil, Exp, Log and Log10 give a Float as in the original, unless an argument is a Double: then they calculate with a Double and give one. A Long or ULong argument is converted to a Float first, so convert it with Double to keep its digits. ^ already calculated with doubles.
  • PopCount, LeadingZeros, TrailingZeros, RotL, RotR and ByteSwap work on the bits of a number with the width of its type.

Home · Command Index



Differences
Language Features
BlitzBasic
Blitz3D
BlitzPlus

Clone this wiki locally