PBXB64 Data Types

26 Data Types PBXB64 Additions

PBXB64 supports all standard PowerBASIC types plus 6 new types not found in any other PB compiler: DEC128 (18-digit decimal), RATIONAL (exact arithmetic), VARIANT (COM-compatible), OBJECT (COM reference), GUID (128-bit UUID), and 128/256/512-bit wide integers.

Complete Type Reference

TypeSizeDescriptionStatus
BYTE8-bitUnsigned integer (0-255)Standard
WORD16-bitUnsigned integer (0-65535)Standard
INTEGER16-bitSigned integer (-32768 to 32767)Standard
LONG64-bitSigned integer (PBXB64 default is 64-bit)Standard
DWORD32-bitUnsigned integerStandard
QUAD64-bitSigned integer aliasStandard
SINGLE32-bitIEEE-754 floatStandard
DOUBLE64-bitIEEE-754 doubleStandard
EXTENDED80-bitExtended precision floatStandard
CURRENCY64-bitFixed-point (×10000)Standard
CURRENCYX16-byteExtended fixed-point (V12)NEW
STRINGDynamicANSI variable-length stringStandard
WSTRINGDynamicWide-character (UTF-16) stringStandard
STRINGZDynamicNull-terminated ANSI stringNEW
WSTRINGZDynamicNull-terminated wide stringNEW
DEC12816-byteDecimal fixed-point, 18-digit precisionNEW
RATIONAL16-byteExact rational (int64 num/den, auto-GCD)NEW
VARIANT16-byteCOM-compatible (VT_I8, VT_R8, VT_BSTR)NEW
OBJECT8-byteCOM object referenceNEW
GUID16-byte128-bit UUIDNEW
128-bit int16-byteInline 128-bit arithmeticNEW
256-bit int32-byteInline 256-bit arithmeticNEW
512-bit int64-byteInline 512-bit arithmeticNEW

DEC128 - 18-Digit Decimal Precision

PBXB64 Addition A 16-byte decimal fixed-point type with 18-digit precision. Ideal for financial calculations where binary floating-point rounding errors are unacceptable.

DEC128 - Financial precision
FUNCTION PBMAIN() AS LONG LOCAL price AS DEC128 LOCAL tax AS DEC128 LOCAL total AS DEC128 price = 19.99 ' Exact decimal tax = 0.07 ' Exact 7% total = price * (1 + tax) ' Result is exact: 21.3893, not 21.389299999999996 PRINT "Total: "; total FUNCTION = 0 END FUNCTION

DEC128 stores values as decimal digits, not binary fractions. 19.99 + 0.01 equals exactly 20.00, not 19.999999999999996.

RATIONAL - Exact Arithmetic

PBXB64 Addition Stores numbers as int64 numerator/denominator pairs with automatic GCD normalization. 1/3 + 1/3 = 2/3 exactly. No rounding, ever.

RATIONAL - Exact fractions
FUNCTION PBMAIN() AS LONG LOCAL a AS RATIONAL LOCAL b AS RATIONAL LOCAL c AS RATIONAL a = 1/3 ' Stored as 1/3, not 0.333... b = 1/6 ' Stored as 1/6 c = a + b ' Result: 1/2 exactly PRINT "1/3 + 1/6 = "; c ' Prints 1/2 FUNCTION = 0 END FUNCTION

RATIONAL automatically reduces fractions (GCD normalization) and supports all arithmetic operations: +, -, *, /, comparison, conversion to/from DECIMAL/DOUBLE.

VARIANT - COM-Compatible Values

PBXB64 Addition Full VARIANT implementation with VT_EMPTY, VT_I8, VT_R8, VT_CY, VT_BOOL, VT_BSTR. Supports scalar, fixed arrays, and dynamic arrays with REDIM PRESERVE.

VARIANT - Dynamic type
FUNCTION PBMAIN() AS LONG LOCAL v AS VARIANT v = 42 ' VT_I8 PRINT VARIANTVT(v) ' 20 (VT_I8) v = "Hello" ' VT_BSTR PRINT VARIANTVT(v) ' 8 (VT_BSTR) v = 3.14159 ' VT_R8 PRINT VARIANTVT(v) ' 5 (VT_R8) FUNCTION = 0 END FUNCTION

VARIANT arrays support element-wise lifecycle management. REDIM PRESERVE performs deep element copy.

Wide Integers - 128 / 256 / 512 Bit

PBXB64 Addition Inline arithmetic on 128, 256, and 512-bit integers. No library calls, no heap allocation - pure register-based operations.

128-bit integer arithmetic
FUNCTION PBMAIN() AS LONG LOCAL a AS __int128 LOCAL b AS __int128 LOCAL c AS __int128 a = 170141183460469231731687303715884105727 ' 2^127-1 b = 2 c = a + b ' 170141183460469231731687303715884105729 PRINT c FUNCTION = 0 END FUNCTION

Wide integers support addition, subtraction, multiplication, division, comparison, and bitwise operations. All done inline in the x64 backend without external libraries.

Try It Yourself

CLI - compile and run
REM DEC128 precision test PBXB64 test_dec128.pb -o test_dec128.exe test_dec128.exe REM RATIONAL exact arithmetic PBXB64 test_rational.pb -o test_rational.exe test_rational.exe REM VARIANT type switching PBXB64 test_variant.pb -o test_variant.exe test_variant.exe REM 128-bit integer PBXB64 test_128bit.pb -o test_128bit.exe test_128bit.exe

All test files are in examples/basic/ - compile and run them to verify.

By The Numbers

23Standard PB types
6PBXB64 additions
512Max bit width
18DEC128 digits

Related Features

Back to Feature List