=encoding utf8

=head1 NAME

Sidef::Types::Number::Fraction - Symbolic support for fractions

=head1 DESCRIPTION

This class implements symbolic support for rational values (fractions) in Sidef. It inherits from L<Sidef::Types::Number::Number>.

=head1 SYNOPSIS

    var f = Fraction(3, 4)
    say f.class         # Fraction

    var a = Fraction(1, 2)
    var b = Fraction(1, 3)

    say (a + b)         # Fraction(5, 6)
    say (a - b)         # Fraction(1, 6)
    say (a * b)         # Fraction(1, 6)
    say (a / b)         # Fraction(3, 2)

    say f.numerator     # 3
    say f.denominator   # 4
    say f.as_float      # 0.75

=head1 INHERITANCE

  Sidef::Types::Number::Fraction
  Sidef::Types::Number::Number
  Sidef::Object::Object

=head1 METHODS

=head2 new

    Fraction(num, den)

Creates a new Fraction object with the given numerator C<num> and denominator C<den>.

=head2 numerator

    f.numerator
    f.num

Returns the numerator of the fraction as an integer.

=head2 denominator

    f.denominator
    f.den

Returns the denominator of the fraction as an integer. The denominator is always positive.

=head2 parts

    f.parts

Returns a list containing the numerator and the denominator.

=head2 int

    f.int
    f.to_i

Returns the integer part of the fraction (truncates towards zero).

=head2 float

    f.float
    f.to_f

Returns the fraction converted to a floating-point number (Sidef Float).

=head2 rat

    f.rat

Returns the object itself, as it is already a rational number.

=head2 inv

    f.inv

Returns the multiplicative inverse (reciprocal) of the fraction ($1/f$).

=head2 abs

    f.abs

Returns the absolute value of the fraction.

=head2 neg

    f.neg
    -f

Returns the negation of the fraction.

=head2 inc

    f.inc

Returns the fraction incremented by 1.

=head2 dec

    f.dec

Returns the fraction decremented by 1.

=head2 sign

    f.sign

Returns -1 if the fraction is negative, 0 if it is zero, and 1 if it is positive.

=head2 ceil

    f.ceil

Returns the smallest integer greater than or equal to the fraction.

=head2 floor

    f.floor

Returns the largest integer less than or equal to the fraction.

=head2 truncate

    f.truncate

Truncates the fraction to an integer (towards zero).

=head2 round

    f.round

Rounds the fraction to the nearest integer.

=head2 is_pos

    f.is_pos

Returns true if the fraction is strictly positive.

=head2 is_neg

    f.is_neg

Returns true if the fraction is strictly negative.

=head2 is_zero

    f.is_zero

Returns true if the fraction is equal to zero.

=head2 is_one

    f.is_one

Returns true if the fraction is equal to one.

=head2 is_int

    f.is_int

Returns true if the fraction represents an integer (denominator is 1).

=head2 is_proper

    f.is_proper

Returns true if the absolute value of the fraction is less than 1 (numerator < denominator).

=head2 is_improper

    f.is_improper

Returns true if the absolute value of the fraction is greater than or equal to 1.

=head2 as_mixed

    f.as_mixed

Returns a list of three elements representing the mixed fraction: integer part, numerator of the remainder, and the denominator.

    var f = Fraction(5, 3)
    say f.as_mixed   # [1, 2, 3]  (representing 1 2/3)

=head2 to_s

    f.to_s

Returns the string representation of the fraction (e.g., "Fraction(3, 4)").

=head2 dump

    f.dump

Returns a string representation of the object for debugging purposes.

=head1 OPERATORS

The following operators are overloaded for C<Sidef::Types::Number::Fraction>:

=over 4

=item *

C<+> (Addition)

=item *

C<-> (Subtraction)

=item *

C<*> (Multiplication)

=item *

C</> (Division)

=item *

C<%> (Modulo)

=item *

C<**> (Exponentiation)

=item *

C<< <=> >> (Comparison)

=back

Additionally, standard boolean comparison operators (C<==>, C<!=>, C<< < >>, C<< <= >>, C<< > >>, C<< >= >>) work as expected.

=head1 AUTHOR

Daniel "Trizen" Șuteu

=head1 LICENSE

This module is free software; you can redistribute it and/or modify it under the same terms as Sidef itself.

=cut
