aftermath-ts-sdk - v3.3.3
    Preparing search index...

    Provides conversions for signed 18-decimal IFixed values.

    IFixed stores the magnitude in a bigint and uses bit 255 as its negative sign bit. The class does not validate that inputs fit a particular serialized width; it applies this sign-bit convention to the supplied bigint.

    Index
    GREATEST_BIT: bigint = ...

    Bit 255, used as the negative sign bit in the 256-bit IFixed encoding.

    NOT_GREATEST_BIT: bigint = ...

    A mask containing every bit below bit 255.

    neg uses this value while flipping the IFixed sign bit.

    ONE: bigint = ...

    The exact IFixed representation of 1.0, 1000000000000000000n.

    • Removes the IFixed sign bit from a value's mathematical magnitude.

      Values greater than or equal to GREATEST_BIT are treated as negative and passed through neg; all other values are returned unchanged.

      Parameters

      • value: bigint

        The IFixed value to inspect.

      Returns bigint

      The non-negative magnitude under the IFixed convention.

    • Converts little-endian bytes to an IFixed bigint.

      The method delegates to Casting.bigIntFromBytes, so the byte order is little-endian and the input array is reversed in place. The resulting bigint is not sign-decoded; bit 255 is interpreted only when another IFixed method reads it.

      Parameters

      • bytes: number[]

        The little-endian IFixed bytes.

      Returns bigint

      The encoded IFixed bigint.

      When the byte array is empty or cannot be converted to a bigint.

    • Converts a JavaScript number to an 18-decimal IFixed bigint.

      The absolute value is multiplied by ONE and floored. Negative inputs then receive the IFixed sign-bit encoding through neg. JavaScript number precision applies before the floor.

      Parameters

      • value: number

        The local number to encode.

      Returns bigint

      The signed IFixed representation.

      RangeError when the scaled value is not finite.

    • Converts decimal byte strings to an IFixed bigint.

      Each string is first converted with Casting.bytesFromStringBytes, then the resulting byte array follows the little-endian and mutation behavior of iFixedFromBytes.

      Parameters

      • bytes: string[]

        Decimal strings such as "255" and "0".

      Returns bigint

      The encoded IFixed bigint.

      When conversion or bigint construction fails.

    • Negates an IFixed value in the sign-bit encoding.

      The operation flips the lower 255 bits, adds one, and flips bit 255. It returns 0n for 0n and is an involution for values represented by this encoding.

      Parameters

      • value: bigint

        The IFixed value to negate.

      Returns bigint

      The negated IFixed value.

    • Converts an IFixed bigint to a JavaScript number.

      The method reads bit 255 as the sign, divides the magnitude by ONE, and adds the integer and fractional parts. The final number can lose precision when the magnitude is larger than JavaScript can represent exactly.

      Parameters

      • value: bigint

        The signed 18-decimal IFixed value.

      Returns number

      The decoded local number.

    • Returns the mathematical sign under the IFixed sign-bit convention.

      Values greater than or equal to GREATEST_BIT return -1. Zero returns 0. All other values return 1.

      Parameters

      • value: bigint

        The IFixed value to inspect.

      Returns number

      -1, 0, or 1.