Ruby | Math ldexp() function Last Updated : 07 Jan, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report The ldexp() function in Ruby returns the value of fraction * (2^exponent) when fraction and exponent are given as parameters. The fraction is a float value and the exponent is an integer. Syntax: Math.ldexp(fraction, exponent) Parameter: The function takes two mandatory parameter fraction and exponent which specifies the fraction and exponent whose result is returned. Return Value: The function returns the value of fraction and exponent. Example 1: CPP # Ruby program for ldexp() function # Assigning values fraction1, exponent1 = Math.frexp(189) fraction2, exponent2 = Math.frexp(19) fraction3, exponent3 = Math.frexp(18) fraction4, exponent4 = Math.frexp(123) # Prints the value returned by ldexp() puts Math.ldexp(fraction1, exponent1) puts Math.ldexp(fraction2, exponent2) puts Math.ldexp(fraction3, exponent3) puts Math.ldexp(fraction4, exponent4) Output: 189.0 19.0 18.0 123.0 Example 2: CPP # Ruby program for ldexp() function # Assigning values fraction1, exponent1 = Math.frexp(23) fraction2, exponent2 = Math.frexp(27) fraction3, exponent3 = Math.frexp(1092) fraction4, exponent4 = Math.frexp(1087) # Prints the value returned by ldexp() puts Math.ldexp(fraction1, exponent1) puts Math.ldexp(fraction2, exponent2) puts Math.ldexp(fraction3, exponent3) puts Math.ldexp(fraction4, exponent4) Output: 23.0 27.0 1092.0 1087.0 Reference: https://devdocs.io/ruby~2.5/math#method-c-ldexp Comment More infoAdvertise with us Next Article Ruby | Math ldexp() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Math-class Similar Reads Ruby | Math log() function The log() function in Ruby returns the logarithm value of X. The second parameter is the base given by the user to which the logarithm value is returned. In case its not given, then the default base is e. Syntax: Math.log(X, base) Parameter: The function takes one mandatory parameter X whose logarit 1 min read Ruby | Math log2() function The log2() function in Ruby returns the base 2 logarithm value of X. Syntax: Math.log2(X) Parameter: The function takes one mandatory parameter X whose base 2 logarithm value is to be returned. Return Value: The function the base 2 logarithm value of X. Example 1: CPP # Ruby program for log2() funct 1 min read Ruby | Matrix lup() function The lup() is an inbuilt method in Ruby returns the LUP decomposition of the given matrix. Syntax: mat1.lup() Parameters: The function needs the matrix whose LUP decomposition is to be returned. Return Value: It returns the LUP decomposition of the matrix. Example 1: CPP #Ruby program for lup() metho 1 min read Ruby | Math log10() function The log10() function in Ruby returns the base 10 logarithm value of X. Syntax: Math.log10(X) Parameter: The function takes one mandatory parameter X whose base 10 logarithm value is to be returned. Return Value: The function the base 10 logarithm value of X. Example 1: CPP # Ruby program for log10() 1 min read Ruby | Math lgamma() function The lgamma() function in Ruby returns two numbers, one represents the logarithmic gamma of value while the other signifies the sign of gamma of value. Syntax: Math.lgamma(value) Parameter: The function takes one mandatory parameter value whose logarithmic gamma is returned and its sign. Return Value 1 min read Like