Structure
Int256
A 256-bit signed integer backed by a UInt128 low limb and an Int128 high limb, conforming to FixedWidthInteger, BinaryInteger, and SignedInteger; the signed counterpart to UInt256.
- iOS 18.0+
- macCatalyst 18.0+
- macOS 15.0+
- tvOS 18.0+
- visionOS 2.0+
- watchOS 11.0+
@frozen struct Int256
Overview
Int256 is the two’s-complement counterpart to UInt256 used where signed arithmetic is needed (e.g. certain BIP-32 child-key derivation intermediate steps or Miller-Rabin witness computations). The high limb is Swift.Int128 so the sign bit lives in its natural position (bit 255); the low limb remains UInt128 to keep addition / subtraction carry logic uniform with the unsigned type. Use init(bitPattern:) to reinterpret the underlying bits as UInt256 (zero-cost), and addingReportingOverflow(_:) when callers need to detect signed overflow without trapping.
Important
Same caveat as UInt256 — operations are not constant-time and must not be used for secret scalar arithmetic.
Topics
Initializers