[Gambas-user] numerical error in Gambas??
jholm at ...381...
jholm at ...381...
Mon Mar 29 14:27:33 CEST 2004
Hi everyone,
I have a rather peculiar problem when I compile the following in Gambas:
PUBLIC SUB Main()
DIM i AS Float
FOR i = 1.66 TO 1.70 STEP 0.001
PRINT i*(1.0/i)
NEXT
END
I get "0.1" values for some of the i values, which is obviously wrong.
By doing the same in C++ (and compiling with g++):
#include <iostream>
using namespace std;
int main(void)
{ for (double i=1.66; i<1.7;i +=0.001){ cout << i*(1/i); };
return 0; }
I get the correct stream of 1's.
I have compiled Gambas directly from source, with no problems in the configure
script (but no db components are compiled).
Is this just my machine? or have I totally misunderstood that division
operator?
Jesper
More information about the User
mailing list