Hello Ivan,
I have finally discovered that the problem has to do with negative numbers in general, at least in the case of QBasic, and is not the origin of the Bankersī Conspiracy to justify Money Lending.
I was using the INT function to get 2 decimal places from a double precision number. This was causing a problem, because it doesnīt only truncate.
Life is full of treacherous traps.
"INT returns the largest integer less than or equal to a numeric expression."
as told by QBasic Help. So, as they say, he who announces his intention, is not a traitor.
Increasing the digit in a negative number makes it less than what it was before. The mind starts bending here, but of course, -2 plus -2 is -4. Itīs smaller...
INT(12.54) 'Output is: 12
INT(-12.54) 'Output is: -13
INT(-(5.001) * 100) / 100: ' output: 5.01 <<<< OH ?? Yes!
INT(-(5.3111) * 100) / 100: ' output: 5.32 <<<< OH ?? Yes!
INT(5.001): ' output: 5
INT(-5.001): ' output: -6 <<<< WHOA!!!! ARGHHHH! Youīre dead!
But now Iīve just discovered a more useful one, even if not perfect:
FIX truncates a floating-point expression to its integer portion.
FIX(12.49) 'Output is: 12
FIX(12.54) 'Output is: 12
FIX(-(5.001) * 100) / 100: ' output is: 5 <<<< Fine.
FIX(-(5.8891) * 100) / 100: ' output is: 5.88 <<<< Well, OK...
Even if FIX wonīt round off anything and just truncates, at least it
wonīt warp the model on the right, so thatīs what Iīll use.
Cheers,
Aleatorylamp
"Why make it simple if you can als
Bookmarks