math.ldexp

From ComputerCraft
Jump to navigation Jump to search

math.ldexp
Function
Syntax
math.ldexp()
Returns number
API math
Source Lua (source)

Compute a floating point number from the given mantissa and exponent. This is the inverse operation of math.frexp, and computes Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle 2\text{mantissa}^{\text{exponent}}} .

ExampleExampleTurn user input into a number
Read a two lines from the user, and compute the floating point number represented by the given mantissa and exponent.
Code
local m = tonumber(read())
local e = tonumber(read())
print(math.ldexp(m, e))
Output Depends on what the user wrote. For instance, if they were to enter 0.625 and 3, the number print would be 5