in reply to Irrational numbers
Certain irrational numbers have a compact but useful representation; for example the squareroot of two can be represented as bless(\'2 ** 0.5', 'Surd'). A suitably smart implementation of the Surd class could figure out that root2 times 3root2 equals 6 without resorting to floating point arithmetic.
The problem with π is that it's not just irrational; it's transcendental. There's no convenient, accurate representation of it. You've just got to store an approximation as a float or string or whatever, and it will only be accurate to a certain number of decimal places.


Replies are listed 'Best First'.  

Re^2: Irrational numbers
by grondilu (Friar) on Dec 17, 2012 at 22:20 UTC  
by tobyink (Abbot) on Dec 18, 2012 at 08:35 UTC 