Fp.opCast

  1. T opCast()
  2. T opCast()
    struct Fp(size_t coefficientSize, Exp = sizediff_t)
    nothrow const
    T
    opCast
    (
    T
    bool noHalf = false
    )
    ()
    if (
    isFloatingPoint!T
    )
    if (
    (
    is(Exp == int) ||
    is(Exp == long)
    )
    &&
    coefficientSize % (size_t.sizeof * 8) == 0
    &&
    coefficientSize >= (size_t.sizeof * 8)
    )
  3. T opCast()

Examples

import mir.bignum.fixed: UInt;
auto fp = Fp!128(1, 100, UInt!128.fromHexString("e3251bacb112cb8b71ad3f85a970a314"));
assert(cast(double)fp == -0xE3251BACB112C8p+172);
import mir.bignum.fixed: UInt;
auto fp = Fp!128(1, 100, UInt!128.fromHexString("e3251bacb112cb8b71ad3f85a970a314"));
static if (real.mant_dig == 64)
    assert(cast(real)fp == -0xe3251bacb112cb8bp+164L);
import mir.bignum.fixed: UInt;
auto fp = Fp!64(1, 100, UInt!64(0xe3251bacb112cb8b));
version (DigitalMars)
{
    // https://issues.dlang.org/show_bug.cgi?id=20963
    assert(cast(double)fp == -0xE3251BACB112C8p+108
        || cast(double)fp == -0xE3251BACB112D0p+108);
}
else
{
    assert(cast(double)fp == -0xE3251BACB112C8p+108);
}
import mir.bignum.fixed: UInt;
auto fp = Fp!64(1, 100, UInt!64(0xe3251bacb112cb8b));
static if (real.mant_dig == 64)
    assert(cast(real)fp == -0xe3251bacb112cb8bp+100L);

Meta