Boundaries of Number in Gupta

Basically, the Number data type is a fine thing in Gupta. You don’t have to deal with int, float, double, decimal etc. as with many other programming languages. There is only Number. In the daily routine of a developer that fits very well. But some days are different. Some days you reach a limit. Recently that happened again.

Number as Bit Field

It is not uncommon to combine several bit flags in one Number variable. Usually you query this with
If( nSomeFlags & SOME_SettingsFlag)

where SOME_SettingsFlag is a constant with a value of 2 ^ n.

Recently we assigned a value of 2 ^ 33 to the SOME_SettingsFlag constant. No problem for a Number variable itself. But when applied to the &-Operator we got a result of 0 in every case.


A quick look at the help file – looking up operator „&“ as well as data type „Number“: unfortunately nothing about value ranges in which they work reliably there. So I did a little research.

& and | work with 4 bytes

For the bitwise AND and OR operators (& and |) it was easy to find out: They work in the range from 0x00000000 to 0xFFFFFFFF. Everything above is cut off.

Number reliable up to 52 Bits

What is the largest integer that one can store in Number? Because the Number type is based on floating-point number, the answer depends on the length of their mantissa. A short test in the debugger shows that the representation of numbers bigger than 2 ^ 52 shows up in exponential notation in the variable watch. A look into Wikipedia substantiates the suspicion: the standard IEEE 754 floating point numbers of type double provides 52 bits for the mantissa, eleven for the exponent, and one for the sign – making a total of 64 bit. In principle, you can store integer numbers with up to 52 bits. Therefor the value range is between +-(2^53-1) or +- or approximately plus minus nine quadrillion.

Man Proposes

While creating a function for bitwise operations for numbers > 32-bit I have written the following line
Set nLower = nOperand & 0xFFFFFFFF

with the following result: When testing with nOperand = 2 ^ 52 Gupta runtime throws an error.


Assigning nOperand = 2 ^ 33 returns 0 without any error message although even this one is too large for the &-operator. Further tests have shown that one gets no error message for numbers up to 48 bit, everything above is producing one.

Gupta Disposes

The &-operator has three value ranges for it’s operands

  1. 0 – 2^32 – works flawlessly
  2. 2^33 – 2^48 – ignores bits beyond 32
  3. > 2^48  – throws an error message


While you may use integers up to +-2 ^ 53-1 with Gupta Number however it is advisable to limit it’s use to 32 bit. Because the integer operators work only with up to 4 bytes. Also the Windows message parameter wParam, lParam, and the return value are limited to 32-bit.

Happy coding.


Über thomasuttendorfer
Ich bin Entwicklungsleiter bei der Softwarefirma [ frevel & fey ] in München. Wir entwickeln Business-Software für Verlage und verwenden dafür den Gupta Team-Developer sowie Visual Studio.

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

Du kommentierst mit Deinem Abmelden / Ändern )


Du kommentierst mit Deinem Twitter-Konto. Abmelden / Ändern )


Du kommentierst mit Deinem Facebook-Konto. Abmelden / Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden / Ändern )

Verbinde mit %s

%d Bloggern gefällt das: