Hardware floating point number. Special values nan and inf aren't allowed.
flag to indicate if the normalization should be performed.
enum h = -33.0 * 2.0 ^^ -10; auto f = Fp!64(h); assert(f.sign); assert(f.exponent == -10 - (64 - 6)); assert(f.coefficient == 33UL << (64 - 6)); assert(cast(double) f == h); // CTFE static assert(cast(double) Fp!64(h) == h); f = Fp!64(-0.0); assert(f.sign); assert(f.exponent == 0); assert(f.coefficient == 0); // subnormals static assert(cast(float) Fp!64(float.min_normal / 2) == float.min_normal / 2); static assert(cast(float) Fp!64(float.min_normal * float.epsilon) == float.min_normal * float.epsilon); // subnormals static assert(cast(double) Fp!64(double.min_normal / 2) == double.min_normal / 2); static assert(cast(double) Fp!64(double.min_normal * double.epsilon) == double.min_normal * double.epsilon); // subnormals static assert(cast(real) Fp!64(real.min_normal / 2) == real.min_normal / 2); static assert(cast(real) Fp!64(real.min_normal * real.epsilon) == real.min_normal * real.epsilon); enum d = cast(float) Fp!64(float.min_normal / 2, false); // subnormals static assert(cast(float) Fp!64(float.min_normal / 2, false) == float.min_normal / 2, d.stringof); static assert(cast(float) Fp!64(float.min_normal * float.epsilon, false) == float.min_normal * float.epsilon); // subnormals static assert(cast(double) Fp!64(double.min_normal / 2, false) == double.min_normal / 2); static assert(cast(double) Fp!64(double.min_normal * double.epsilon, false) == double.min_normal * double.epsilon); // subnormals static assert(cast(real) Fp!64(real.min_normal / 2, false) == real.min_normal / 2); static assert(cast(real) Fp!64(real.min_normal * real.epsilon, false) == real.min_normal * real.epsilon);
Without normalization
auto f = Fp!64(-33.0 * 2.0 ^^ -10, false); assert(f.sign); assert(f.exponent == -10 - (double.mant_dig - 6)); assert(f.coefficient == 33UL << (double.mant_dig - 6));
Constructs Fp from hardaware floating point number.