3 ms·
That makes sense, but unfortunately the Pyret page says nothing to indicate that arithmetic is done in the rational field. For the record, 1.0 compares equal t
by mgraczyk 12y ago
That makes sense, but unfortunately the Pyret page says nothing to indicate that arithmetic is done in the rational field.
For the record, 1.0 compares equal to (1.0 / 3) * 3 in IEEE 754 32-bit floating point arithmetic. You may want to consider a more compelling example, ie
float x = 1.0;
for (int i = 0; i < 10; ++i) {
x += 1.0 / 10;
}
x == 1.0 // False
- shriramkmurthi 12y agoSure. In general there are lots of examples that illustrate the ugliness of using floating points _unnecessarily_.