in reply to Irrational numbers
Certain irrational numbers have a compact but useful representation; for example the square-root of two can be represented as bless(\'2 ** 0.5', 'Surd'). A suitably smart implementation of the Surd class could figure out that root-2 times 3-root-2 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.
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Irrational numbers
by grondilu (Friar) on Dec 17, 2012 at 22:20 UTC | |
by tobyink (Canon) on Dec 18, 2012 at 08:35 UTC |
In Section
Meditations