The OpenD Programming Language

Fp.this

  1. this(bool sign, long exponent, UInt!size normalizedCoefficient)
  2. this(T value, bool normalize)
  3. this(UInt!isize integer, bool normalizedInteger)
    struct Fp(uint size)
    nothrow
    this
    (
    uint isize
    )
    (,
    bool normalizedInteger = false
    )
    if (
    size % (uint.sizeof * 8) == 0 &&
    size >= (uint.sizeof * 8)
    )
  4. this(ulong value)
  5. this(long value)
  6. this(int value)
  7. this(uint value)

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