SINTEGER Arithmetic problems
Sharpdog
Posts: 7
Perhaps I'm missing something simple here.
I'm trying to subtract 1,440 (the minutes in a day)
from a SINTEGER. My code goes something like this:
SINTEGER nX; //Variable definition
.
.
.
if (some condition) {
nX = nX - 1440;
}
This produces a warning that I am "converting type [SINTEGER] to [INTEGER]"
I've tried Defining a SINTEGER constant to equal 1440 and subtract that, but
then it complains that my SINTEGER constant is a conversion.
I've tried to putting TYPE_CAST ( ) around various parts of the equation, but
may not be using it correctly.
Any suggestions or insights would be MOST appreciated!!
And if there's documentation I have missed that explains my confusion
I would DEFINITELY appreciate a pointer to said documentation.
-Preston |8-)
I'm trying to subtract 1,440 (the minutes in a day)
from a SINTEGER. My code goes something like this:
SINTEGER nX; //Variable definition
.
.
.
if (some condition) {
nX = nX - 1440;
}
This produces a warning that I am "converting type [SINTEGER] to [INTEGER]"
I've tried Defining a SINTEGER constant to equal 1440 and subtract that, but
then it complains that my SINTEGER constant is a conversion.
I've tried to putting TYPE_CAST ( ) around various parts of the equation, but
may not be using it correctly.
Any suggestions or insights would be MOST appreciated!!
And if there's documentation I have missed that explains my confusion
I would DEFINITELY appreciate a pointer to said documentation.
-Preston |8-)
0
Comments
In NetLinx, integrals 256 or higher seem to act like "integer." You need to type_cast your number, so
Yet another NetLinx compiler bug. Sigh...
How did you define your constant?
If you did this:
Then you should get a Converting type [SINTEGER] to [INTEGER] warning. I can?t get the SINTEGER constant is a conversion error but that?s just an aside.
If instead you do this:
Then the compiler is satisfied and you can use a constant for your math without any type casting.
Just wanted to throw that out there as an option.
Off by one would be nice. I've seen them off by 20 or 30 because of bad tracking of include files.
Then there's always the fun error messages with no line numbers:
ERROR: (0): C10580: Internal Error: Major system error occurred during code generation
By the way, nice job Joe on the the braces advice. I think I've always type_cast in that situation.
--John
Thank You to all of you for your posts especially true and Joe for their solutions.
AMX Programming.... Never a dull moment!!
-Preston |8-)