Fp.this

  1. this(bool sign, Exp exponent, UInt!coefficientSize normalizedCoefficient)
  2. this(T value, bool normalize)
  3. this(UInt!size integer, bool normalizedInteger)
    struct Fp(size_t coefficientSize, Exp = sizediff_t)
    nothrow
    this
    (
    size_t size
    )
    (,
    bool normalizedInteger = false
    )
    if (
    (
    is(Exp == int) ||
    is(Exp == long)
    )
    &&
    coefficientSize % (size_t.sizeof * 8) == 0
    &&
    coefficientSize >= (size_t.sizeof * 8)
    )

Examples

import mir.bignum.fixed: UInt;

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

fp = Fp!128(UInt!128.fromHexString("afbbfae3cd0aff2714a1de7022b0029d"), true);
assert(fp.exponent == 0);
assert(fp.coefficient == UInt!128.fromHexString("afbbfae3cd0aff2714a1de7022b0029d"));

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

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

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

fp = Fp!128(UInt!64.fromHexString("e7022b0029dd0aff"), true);
assert(fp.exponent == -64);
assert(fp.coefficient == UInt!128.fromHexString("e7022b0029dd0aff0000000000000000"));

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

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

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

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

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

Meta