BigUIntView.opCast

  1. T opCast()
  2. T opCast()
    struct BigUIntView(W, WordEndian endian = TargetEndian)
    @safe scope const
    T
    opCast
    (
    T : Fp!coefficientSize
    size_t internalRoundLastBits = 0
    bool wordNormalized = false
    bool nonZero = false
    size_t coefficientSize
    )
    ()
    if (
    internalRoundLastBits < size_t.sizeof * 8 &&
    (
    size_t.sizeof >= W.sizeof ||
    endian == TargetEndian
    )
    )
    if (
    __traits(isUnsigned, W)
    )
  3. T opCast()
  4. BigUIntView!V opCast()

Examples

import mir.bignum.fp: Fp;
import mir.bignum.fixed: UInt;

auto fp = cast(Fp!128) BigUIntView!ulong.fromHexString("afbbfae3cd0aff2714a1de7022b0029d");
assert(fp.exponent == 0);
assert(fp.coefficient == UInt!128.fromHexString("afbbfae3cd0aff2714a1de7022b0029d"));

fp = cast(Fp!128) BigUIntView!uint.fromHexString("ae3cd0aff2714a1de7022b0029d");
assert(fp.exponent == -20);
assert(fp.coefficient == UInt!128.fromHexString("ae3cd0aff2714a1de7022b0029d00000"));

fp = cast(Fp!128) BigUIntView!ushort.fromHexString("e7022b0029d");
assert(fp.exponent == -84);
assert(fp.coefficient == UInt!128.fromHexString("e7022b0029d000000000000000000000"));

fp = cast(Fp!128) BigUIntView!ubyte.fromHexString("e7022b0029d");
assert(fp.exponent == -84);
assert(fp.coefficient == UInt!128.fromHexString("e7022b0029d000000000000000000000"));

fp = cast(Fp!128) BigUIntView!size_t.fromHexString("e7022b0029d");
assert(fp.exponent == -84);
assert(fp.coefficient == UInt!128.fromHexString("e7022b0029d000000000000000000000"));

fp = cast(Fp!128) BigUIntView!size_t.fromHexString("ffffffffffffffffffffffffffffffff1000000000000000");
assert(fp.exponent == 64);
assert(fp.coefficient == UInt!128.fromHexString("ffffffffffffffffffffffffffffffff"));

fp = cast(Fp!128) BigUIntView!size_t.fromHexString("ffffffffffffffffffffffffffffffff8000000000000000");
assert(fp.exponent == 65);
assert(fp.coefficient == UInt!128.fromHexString("80000000000000000000000000000000"));

fp = cast(Fp!128) BigUIntView!size_t.fromHexString("fffffffffffffffffffffffffffffffe8000000000000000");
assert(fp.exponent == 64);
assert(fp.coefficient == UInt!128.fromHexString("fffffffffffffffffffffffffffffffe"));

fp = cast(Fp!128) BigUIntView!size_t.fromHexString("fffffffffffffffffffffffffffffffe8000000000000001");
assert(fp.exponent == 64);
assert(fp.coefficient == UInt!128.fromHexString("ffffffffffffffffffffffffffffffff"));

Meta