-
Notifications
You must be signed in to change notification settings - Fork 51
Description
Bug report
i thought the int() function should behave like the C runtime floor() function, but it seems to misbehave
on values greater than -1.0 and smaller than 0.0
int(-0.6) returns zero, i expected -1
am i misunderstanding some subtely of the int() function, or is it really a bug?
Program
10 POS1=1.6
20 POS0=.6
30 POSM0=-.6
40 POSM1=-1.6
50 PRINT " val: ",POS1,POS0,POSM0,POSM1
60 PRINT "int expect: ",1,0,-1,-2
70 IPOS1=INT(POS1)
80 IPOS0=INT(POS0)
90 IPOSM0=INT(POSM0)
100 IPOSM1=INT(POSM1)
110 PRINT " got: ",IPOS1,IPOS0,IPOSM0,IPOSM1
120 IIPOS1=INT(1.6)
130 IIPOS0=INT(.6)
140 IIPOSM0=INT(-.6)
150 IIPOSM1=INT(-1.6)
160 PRINT" still got: ",IIPOS1,IIPOS0,IIPOSM0,IIPOSM1
Ok
run
val: 1.6 .6 -.6 -1.6
int expect: 1 0 -1 -2
got: 1 0 0 -2
still got: 1 0 0 -2
Ok
PC-BASIC version: 1.2
Operating system version: win7/64
thank-you for a cool retro toy :)