I can't see where is the problem.
A "const" is not a variable. It has no memory location. Declaring a const doesn't create any "object". The compiler will internally create and hold a simple value tagged with the correct type obtained either from the numerical constant used, or from the deduced type of the expression affected to it. This tagged (value, type) will be used anywhere you use your "const" in an expression.
When you put
Code: Select all
Public Const TemperatureMultiplier = 64
Public Const ReadyThreshold3 = 3.0 * TemperatureMultiplier
dim i as integer
ReadyThreshold3 is replaced by a Float. So when you write
Code: Select all
i = ReadyThreshold3 // int 192
i = ReadyThreshold3 + i // floating point add
First affectation of i is done by converting the Float expression to int.
Second affect, compiler will obviously replace ReadyThreshold3 with the Float expression, and thus apply float addition (Float + integer is done by first converting the int to float).
I don't see where is the incorrect behaviour. If you want that compiler generate integer arithmetic, you need to tag your expression with correct type (this is what you have done using AS WORD).