Skip to content

Tag Archives: Ruby Rational-class

The Rational() is an inbuilt method in Ruby returns the rational number of the form a/b. Syntax: Rational(num, den) Parameters: The function accepts two parameters… Read More
The rationalize() is an inbuilt function in Ruby returns a simpler approximation of the value if the optional argument eps is given (rat-|eps| <= result… Read More
The round() is an inbuilt function in Ruby returns rational rounded to the nearest value with a precision of ndigits decimal digits. ndigits by default… Read More
The positive?() is an inbuilt function in Ruby returns boolean value true if rational number is greater than zero otherwise false Syntax: rat.positive?() Parameters: The… Read More
The negative?() is an inbuilt function in Ruby returns boolean value true if rational number is less than zero otherwise false. Syntax: rat.negative?() Parameters: The… Read More
The quo() is an inbuilt function in Ruby returns the rational number by performing division. Syntax: rat1.quo(rat2) Parameters: The function accepts a single parameter Return… Read More
The numerator() is an inbuilt function in Ruby returns the numerator. Syntax: rat.numerator() Parameters: The function accepts no parameter Return Value: It returns the numerator… Read More
The inspect() is an inbuilt function in Ruby returns the value as a string. Syntax: rat.inspect() Parameters: The function accepts no parameter Return Value: It… Read More
The floor() is an inbuilt function in Ruby returns the largest number less than or equal to rat with a precision of ndigits decimal digits.… Read More
The fdiv() is an inbuilt function in Ruby returns float by performing division.  Syntax: rat.fdiv(numeric)Parameters: The function accepts a single parameterReturn Value: It returns float… Read More
The denominator() is an inbuilt function in Ruby returns the denominator which is always positive. Syntax: rat.denominator() Parameters: The function accepts no parameter Return Value:… Read More
The ceil() is an inbuilt function in Ruby returns the smallest number greater than or equal to rat with a precision of ndigits decimal digits.… Read More
The to_f() is an inbuilt function in Ruby returns the float value Syntax: rat.to_f() Parameters: The function accepts no parameter Return Value: It returns the… Read More
The to_i() is an inbuilt function in Ruby returns the truncated integer value Syntax: rat.to_i() Parameters: The function accepts no parameter Return Value: It returns… Read More
The to_r() is an inbuilt function in Ruby returns it’s own value Syntax: rat.to_r() Parameters: The function accepts no parameter Return Value: It returns it’s… Read More