BASIC glitches
ZXNet echo conference «code.zx»
From Fedy Savin → To All 28 June 2000
Hello, All!
The other day I wanted to do a little program on bass with the evil ones
mathematical calculations and found a very unpleasant
a glitch that ruins everything for me. :( so I want to share with you.
the thing is this: let’s say the variable a = 10.000000501
you do PRINT a, it gives exactly 10
and if a=10.000000502 it produces 10.000001
and if more than 9.9999999, then the print also gives exactly 10.
but to hell with it. Next comes the cooler stuff.
I write a line
IF а=10 THEN STOP
and this check only works in the aisles if a>=10 and
a<10.00000001
ok if he cut the fraction evenly when checking
and when printing. otherwise you type PRINT and it gives exactly 10
and if you type IF a=10 THEN STOP it works like crazy.
Maybe there is some way to cut off fractional numbers at least
up to six characters?
And in general, what do you think about this subject?
Best regards, Fedy Savin/Discovery
From Aleksandr Majorov → To Fedy Savin 30 June 2000
Hello Fedy!
28 Jun 00 16:10, Fedy Savin -> All:
[skipped]
FS> the thing is this: let's set the variable a=10.000000501
FS> do PRINT a, it gives exactly 10
FS> and if a=10.000000502 produces 10.000001
yyy, and if a=10.00000501 (one less zero),
then it produces 10.000005
FS> and if more than 9.9999999 , then it also prints exactly 10.
FS> but to hell with it. Next comes a cooler thing.
FS> I write the line
FS> IF а=10 THEN STOP
FS> and this check only works within the limits if a>=10 and
FS> a<10.00000001
FS> okay, if he cut the fraction evenly when checking
FS> and when printing. otherwise you type PRINT and it gives exactly 10
FS> and if you type IF a=10 THEN STOP it doesn't work.
This is IMHO the features of the calculator and the presentation of numbers.
If I'm not mistaken, the calculator has some
number of errors.
It is quite possible that the command "convert packed
A 5-byte (or 4???) number in ASCII form" truncates the number.
Well, all sorts of comparisons work directly with numbers, so
and it turns out like this.
Any calculator has a limit of accuracy.
IMHO you just married him :))))))) FS> Maybe there is some way to cut off fractional numbers
FS> at least up to six characters?
standard method:
a = (int (x * 1000)) / 1000
We round this up to 3 digits.
By analogy, you can round up to 6 :)))))
Only if your whole part is large, then glitches are possible!!!
In the sense that you will get the error “the number is too large”
FS> And in general, what do you think about this subject?
There is a glitch, it cannot help but exist! :)
True, I caught such jokes on the PC :)))))
Alexand