Function glm::builtin::frexp
[−]
[src]
pub fn frexp<F: BaseFloat, I: GenIType, T: FloatIntRel<F, i32, I>>(
x: T
) -> (T, I)
Splits x into a floating-point significand in the range [0.5, 1.0) and
an integral exponent of two, such that:
x = significand⋅2exponent.
For a floating-point value of zero, the significant and exponent are both zero.
For a floating-point value that is an infinity or is not a number, the results are undefined.
Note
In GLSL, the significand is returned by the function and the exponent is
returned in the output parameter exp. In Rust, we have the luxury to
return both of them very naturally via a tuple.
Example
use glm::{ frexp, dvec3, ivec3 }; assert_eq!(frexp(0_f32), (0., 0)); let v3 = dvec3(1024., 1., 3.); let s = dvec3(0.5, 0.5, glm::exp2(glm::log2(3.) - 2.)); let e = ivec3(11, 1, 2); assert_eq!((s, e), frexp(v3));