Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

68 lines (36 sloc) 1.324 kb
=begin pod
=TITLE role Real
role Real does Numeric { ... }
Common role for non-Complex numbers.
=head1 Methods
=head2 Rat
method Rat(Real:D: Real $epsilon = 1e-6)
Converts the number to a C<Rat> with the precision C<$epsilon>.
=head2 rand
sub term:<rand> returns Num:D
method rand(Real:D:) returns Real:D
Returns a pseudo-random number between zero and the number.
The term form returns a pseudo-random C<Num> between 0e0 and 1e0.
=head2 sign
method sign(Real:D:)
Returns C<-1> if the number is negative, C<0> if it is zero and C<1>
=head2 round
method round(Real:D: $scale = 1)
Rounds the number to scale C<$scale>. If C<$scale> is 1, rounds to an
integer. If scale is C<0.1>, rounds to one digit after the comma etc.
=head2 floor
method floor(Real:D) returns Int:D
Return the largest integer not greater than the number.
=head2 ceiling
method ceiling(Real:D) returns Int:D
Returns the smallest integer not less than the number.
=head2 truncate
method truncate(Real:D) returns Int:D
Rounds the number towards zero.
=head2 base
method base(Real:D: Int:D $base where 2..36) returns Str:D
Converts the number to a string, using C<$base> as base. For C<$base> larger
than ten, capital latin letters are used.
255.base(16) # 'FF'
=end pod
Jump to Line
Something went wrong with that request. Please try again.