I'm having trouble with simple integer addition. When I do calculations with integers, I get a real number approximation back. e.g., (17 + 12)-30 produces something like -0.969697
do I need to do something to convert values to integers before doing calculations? It doesn't help to just round the result as I am getting results that are off by 1 that way.
It seems to work fine when I type into the message box, but in handlers I get the realvalue. I'm attaching a trace from a function that shows the error.
Thanks for any suggestions.
addition bug?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: addition bug?
Hi.
You get what???
Convert values? No you don't, and setting the numberformat property does not affect the significant portion of the result.
Are you saying that if you have this in a button:
you do not get "-1"
Craig Newman
You get what???
Convert values? No you don't, and setting the numberformat property does not affect the significant portion of the result.
Are you saying that if you have this in a button:
Code: Select all
on mouseUp
answer (17 + 12)-30
end mouseUp
Craig Newman
Re: addition bug?
Sort of.
I have 3 scroll bars setting values (the thumb position). When I do addition with those values, I get approximate real results (17+12)-30 is about -1
It may be that thumbpositions are reals? I tried to attach a screenshot showing a debug trace with the first message. The values appear as integers in the trace. Rounding the thumbpositions values seems to do the trick.
I have 3 scroll bars setting values (the thumb position). When I do addition with those values, I get approximate real results (17+12)-30 is about -1
It may be that thumbpositions are reals? I tried to attach a screenshot showing a debug trace with the first message. The values appear as integers in the trace. Rounding the thumbpositions values seems to do the trick.
Re: addition bug?
Ah.
Yes. The answer is no.
Though they display as integers, they are reals. There was a thread on this several months back. It is not obvious, but has become part of the LC lore. Try to find the thread, but in the meantime, the "trunc" function is your friend.
Craig Newman
Yes. The answer is no.
Though they display as integers, they are reals. There was a thread on this several months back. It is not obvious, but has become part of the LC lore. Try to find the thread, but in the meantime, the "trunc" function is your friend.
Craig Newman