Package com.io7m.jnfp.core
Class NFPUnsignedFloatLong
java.lang.Object
com.io7m.jnfp.core.NFPUnsignedFloatLong
Conversion of unsigned normalized fixed-point values to and from floating point values.
The OpenGL 3.3 specification defines the conversion from floating point
values x (implied to be in the range [0, 1]) to unsigned
normalized fixed-point values f, with b bits of precision,
as:
f = x * (pow(2, b) - 1)
The specification defines the conversion from unsigned normalized
fixed-point values f with b bits of precision to floating
point values x as:
x = f / (pow(2, b) - 1)
-
Method Summary
Modifier and TypeMethodDescriptionstatic floatfromUnsignedNormalized(long f, int b) Convertfto floating point format.static longtoUnsignedNormalized(float x, int b) Convertxto fixed-point format.
-
Method Details
-
fromUnsignedNormalized
public static float fromUnsignedNormalized(long f, int b) Convertfto floating point format.fis assumed to be an unsigned fixed-point value withbbits of precision.- Parameters:
f- A value in the range[0, (2 ^ b) - 1]b- A value in the range[2, 32]- Returns:
- A floating point value in the range
[0, 1]
-
toUnsignedNormalized
public static long toUnsignedNormalized(float x, int b) Convertxto fixed-point format.- Parameters:
x- A value in the range[0, 1]b- A value in the range[2, 32]- Returns:
- An unsigned normalized fixed-point value with
bbits of precision
-