math.frexp

From ComputerCraft
Jump to navigation Jump to search

math.frexp
Function
Syntax
math.frexp()
Returns number mantissa, number exponent
API math
Source Lua (source)

Return the mantissa and exponent of num, two numbers 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 m} and 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 e} such that 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 \text{num} = 2m^e}

ExampleExampleDecompose user input input
Read a line from the user, then print the mantissa and exponent of the number they entered.
Code
print(math.frexp(tonumber(read())))
Output Depends on what the user wrote. For instance, if they were to enter 5, the numbers printed would be 0.625 3.