Qbasicnews.com

Full Version: computer adds .1 9 times and comes up with .8000001
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
actually at 2bits I might be beat also. four works
Just because it views in 32bits doesn't meen it can't handle a 64 bit problem. It just meens you have to "teach it".
There are two solutions to this problem; both are very easy to implement. The first is to round your answer to the number of decimal points that you want:

Code:
CLS
DO
  PRINT USING "###.#"; b!;
  b! = b! + .1
  a% = a% + 1
LOOP UNTIL a% = 70

The second solution, which has already been posted by Nex, is to use fixed-point:

Code:
CONST DIV = 1000
CLS
DO
  PRINT b& / DIV,
  b& = b& + .1 * DIV
  a% = a% + 1
LOOP UNTIL a% = 70
Pages: 1 2 3