Front page | perl.perl6.users |
Postings from September 2018
September 17, 2018 05:54
Message ID: email@example.com
On 9/16/18 7:37 PM, Curt Tilmes wrote:
> Rat is a type (a 'class').
> It is also a method on class Numeric. You can take anything Numeric,
> and call .Rat() on it to get an equivalent Rat (well, within $epsilon)
> You can't, for example, say
> my Rat $x = pi;
> Since pi is not rational -- it won't fit in that box.
> You can, however, ask pi to turn itself into a Rat (or something pretty
> close), then it will fit.
> my Rat $x = pi.Rat;
I just wrapped my brain around "Role" (Real) being
a superset of "Class" (Rat). When you tell somethig
it isa Rol, it can take on any of the clasees in its subset.
If yo want somethinbg specific, use a class.
And now I understand.
Just out of curiosity, how does Perl handle an
irrational number, like pi or the square root of two?
A number that keeps going on and on and on ...
As an engineer, it is all about significance. 1.0
is not the same as 1.00 to an engineer. So
we don't care about run on numbers. We just
use the significant part.