significand
significand(x)
Extract the significand(s)
(a.k.a. mantissa), in binary representation, of
a floating-point number or array. If x
is a non-zero finite number,
than the result will be a number of the same type on the interval
$[1,2)$. Otherwise x
is returned.
julia> significand(15.2)/15.2
0.125
julia> significand(15.2)*8
15.2
Examples
The significand(x)
function in Julia extracts the significand (also known as mantissa) in binary representation of a floating-point number or array. If the input x
is a non-zero finite number, the result will be a number of the same type within the interval [1, 2)
. If x
is not a finite number, it is returned as is.
Here are some examples of how the significand
function can be used:
-
Extract significand of a floating-point number:
julia> significand(15.2) 0.125
In this example, the significand of the floating-point number
15.2
is extracted and returned as0.125
. - Multiply the significand by a factor:
julia> significand(15.2) * 8 15.2
Here, the significand of
15.2
is multiplied by8
, resulting in the original value15.2
.
Common mistake example:
julia> significand(0)
ERROR: DomainError with 0.0:
significand is only defined for non-zero finite numbers.
In this example, the input 0
is not a finite number, so the significand
function throws a DomainError
. Make sure to provide a non-zero finite number as input to significand
to avoid this error.
See Also
cmp, float, get_bigfloat_precision, get_rounding, get_zero_subnormals, isapprox, maxintfloat, mod2pi, nextfloat, precision, prevfloat, rationalize, round, set_bigfloat_precision, set_rounding, set_zero_subnormals, significand, with_bigfloat_precision, with_rounding,User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.