Expressing Large Numbers in InstallScript

InstallShield 2015

When a number is stored in an InstallScript integer, only 31 bits of data are available to store the value. Therefore, the maximum value that can be expressed is 2^31 (2 GB). Note also that since InstallScript integers are always considered to be signed, the 32 bit is interpreted as the sign bit and cannot be used to store numeric data. This limits the values that can be expressed to 2^31 (2 GB) instead of 2^32 (4 GB), which could be stored in an unsigned data type.

In some cases, it is necessary or desirable to be able to specify larger values. To accomplish this in InstallShield, a number of functions support the specification of large numbers as a pair of 32-bit numbers with the sign bit (32 bit) of each number always being set to 0 to indicate a positive number. Using this format, it is possible to specify and retrieve a number with up to 62 bits of data or 2^62 of size.

Note however that since the language does not have a data type that can express the number as a single variable, the operations that can be performed on this data are limited. This data is typically passed between functions that support these values. The data can also be converted to a single value expressed in a larger size unit (such as KB or MB) using the ConvertSizeToUnits function or passed to an external DLL function that can handle larger data types.

When a number is specified as a high/low pair, the lower 32-bit value specifies the lower 31 bits of data (with the sign bit always set to 0 and ignored) of the full value. The upper 32-bit value specifies the upper 31 bits of data (again with the sign bit always set to 0 and ignored). For example, an upper value of 4 actually indicates 4 * 2^31 or 8589934592 (8 GB) of size. This, combined with a lower value of 100, would indicate a total size of 8589934692 units.

Note that in the case of numbers less than 2^31, the high value will always be 0 and thus can be ignored if you are sure that the size of the value will never exceed 2^31. However, it is recommended that if you need to use this data for computations, you use the ConvertSizeToUnits function to convert this data to a single value of the most appropriate units with minimal amount of rounding to express the data in a single value.

Note: Note that convention differs from the unsigned high/low value pairs used by Windows in which the lower value stores the lower 32 bits of data and the high value stores the upper 32 bits of data. The ConvertWinHighLowSizeToISHighLowSize function is provided for easy conversion of data returned by Windows API functions.

The following functions support high/low value pairs:

GetDiskInfo
GetFileInfo
GetAndAddFileCost
CalculateAndAddFileCost
GetAndAddAllFilesCost
FeatureFileInfo
FeatureGetCostEx
FeatureAddCost
FeatureSpendCost
ConvertWinHighLowSizeToISHighLowSize
ConvertSizeToUnits