SofaBuffers TypeScript - v0.9.0
    Preparing search index...

    Class Long

    A 64-bit integer value carried as two unsigned 32-bit halves.

    SofaBuffers accepts bigint at every 64-bit surface for ergonomics, but a bigint in the encode/decode hot path is expensive — especially on JavaScriptCore (Bun), where profiling showed the bigint split/materialise and zig-zag operations dominating the 64-bit array codecs. Long lets a caller (and the generated code) stay entirely on number arithmetic: the codec reads .low/.high directly, and any bigintLong conversion happens once at the API boundary rather than once per encode.

    Values are stored as raw two's-complement bits; the same Long serves an unsigned or signed field — Long.toBigInt takes the signedness.

    Index
    • Parameters

      • low: number
      • high: number

      Returns Long

    high: number

    High 32 bits (unsigned).

    low: number

    Low 32 bits (unsigned).

    ZERO: Long = ...

    The 64-bit zero. Long is immutable (readonly halves), so this single shared instance is safe to reuse anywhere a zero default is needed — generated code uses it for fixed-count array defaults and pad-fill instead of Long.fromValue(0), which would run bigint arithmetic per call on the hot decode/encode path.

    • Materialise as a bigint. signed reads the high bit as two's complement.

      Parameters

      • signed: boolean = false

      Returns bigint

    • Decimal string (signed interprets the high bit as two's complement).

      Parameters

      • signed: boolean = false

      Returns string

    • Split a bigint into its low/high 32-bit halves (two's complement).

      Parameters

      • value: bigint

      Returns Long

    • Construct from raw 32-bit halves.

      Parameters

      • low: number
      • high: number

      Returns Long

    • From an integer number (|n| < 2^53); sign handled via bigint once.

      Parameters

      • n: number

      Returns Long

    • Accept a Long as-is, or convert a bigint / number once.

      Parameters

      • v: number | bigint | Long

      Returns Long