Long Variable Not Getting Assigned Correctly Through Math Operation
Written by Peter Stauber
Updated at January 14th, 2026
Table of Contents
Symptoms
Two numbers are multiplied that should result in a value greater than 65,535 and are assigned to a LONG variable. The result is incorrect and always less than 65,536.
Example:
DEFINE_VARIABLE
long A_LONG_NUMBER
DEFINE_EVENT
BUTTON_EVENT[128,1]
{
PUSH:
{
A_LONG_NUMBER = (360 * 1000) // result is 32320, should be 3600000
}
}
Cause
This is a compiler bug, constant multiplication is not casting properly. Since constants are integers, the result the compiler used is an integer and data is lost.
Resolution
The interpreter works properly, so move constants to the variable section, and it will work.
DEFINE_VARIABLE
long A_LONG_NUMBER
integer X = 360
integer Y = 1000
DEFINE_EVENT
BUTTON_EVENT[128,1]
{
PUSH:
{
A_LONG_NUMBER = (X * Y) // result is 3600000
}
}
Related Videos
Table of Contents