4 ms·
"Pyret has numbers, because we believe an 8GB machine should not limit students to using just 32 bits." Java Pyret // this is not true
by mgraczyk 12y ago
"Pyret has numbers, because we believe an 8GB machine should not limit students to using just 32 bits."
Java Pyret
// this is not true # this is true
((1 / 3) * 3) == 1 ((1 / 3) * 3) == 1
wat
How about ((1.0 / 3) * 3) == 1? Not sure what point they are trying to make here. Did somebody change the definition of "number" to mean "floating point type?"
- JonathonW 12y agoFrom what I'm reading, Pyret numbers are either exact rational numbers (which includes integers) or inexact floating point numbers (presumably, they're disambiguating this by whether or not you use a decimal point).
- mgraczyk 12y agoNice. Still, it's unsettling that they've confounded address space size with integral type width.
- dragonwriter 12y agoAvailable RAM (something 8GB plausibly could refer to, unlike address-space size) is arguably more relevant to the issue here (which is the desirability of not using fixed-width integers and floating point but instead preferring arbitrary-precision rational numbers as the default.)
- shriramkmurthi 12y agoThat is indeed our point. Thanks for explaining it!
- fineIllregister 12y agoIn Pyret, (1 / 3) resolves to (1 / 3), not 0.3333333333333333 or some equivalent, like it does in many other languages. (0.3333333333333333 * 3) is 0.999999999999999, not 1.
- mgraczyk 12y agoThat 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_.