=begin pod

=TITLE role Real

=SUBTITLE Non-complex number

    role Real does Numeric { ... }

Common role for non-Complex numbers.

=head1 Methods

=head2 method Rat

    method Rat(Real:D: Real $epsilon = 1e-6)

Converts the number to a C<Rat> with the precision C<$epsilon>.

=head2 routine 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 method sign

    method sign(Real:D:)

Returns C<-1> if the number is negative, C<0> if it is zero and C<1>
otherwise.

=head2 method 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 method floor

    method floor(Real:D) returns Int:D

Return the largest integer not greater than the number.

=head2 method ceiling

    method ceiling(Real:D) returns Int:D

Returns the smallest integer not less than the number.

=head2 method truncate

    method truncate(Real:D) returns Int:D

Rounds the number towards zero.

=head2 method base

    method base(Real:D: Int:D $base where 2..36, $digits?) 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'

The optional C<$digits> argument asks for that many digits of fraction
(which may not be negative).  If omitted, a reasonable default is chosen
based on type.  For Int this default is 0.  For L<Num|/type/Num>, the default is 8.
For L<Rational|/type/Rational>, the number of places is scaled to the size of the denominator,
with a minimum of 6.

The final digit produced is always rounded.

    say pi.base(10, 5);     # 3.14159

To convert a string to a number use the C<:16($string)> notation where 16 is
the base:

    say :16("FF")           # 255
    say :23("FF")           # 360

=end pod
