Forum Navigation
You need to log in to create posts and topics.

FB Can't count!?

Posted by: benjamen <benjamen@...>

Can someone please try this code for me. As the demo will show you, if
BOTH of the passed vars exceed 100001 and 10001, then the calculations
turn out incorrect!
I thought the brackets might be causing the long to be clipped to a
short, but in all cases the results are off by only 1 ??

Jamin

---- Cut Here For Code Snippet ------

WINDOW OFF

DIM gUserQuits%
END GLOBALS

LOCAL FN BadCalculation(VauleOne&,ValueTwo&)
PRINT VauleOne&;"-";ValueTwo&;" = ";

Incorrect& = (VauleOne&) -ValueTwo&
Correct& = VauleOne& -ValueTwo&

PRINT Incorrect&;

IF Correct& Incorrect& THEN PRINT ;" <- WRONG! Should be:";Correct&
ELSE PRINT ""

END FN

WINDOW 1
TEXT _monaco,9,0,0

FN BadCalculation(100000,10000)
FN BadCalculation(100001,10000)
FN BadCalculation(100000,10001)
FN BadCalculation(100001,10001)
FN BadCalculation(100002,10002)

DO
HANDLEEVENTS
UNTIL gUserQuits%
END