| Copyright | (c) 2025 Jared Tobin |
|---|---|
| License | MIT |
| Maintainer | Jared Tobin <jared@ppad.tech> |
| Safe Haskell | None |
| Language | Haskell2010 |
Data.Word.Limb
Description
The primitive Limb type, as well as operations on it.
Synopsis
- newtype Limb :: TYPE 'WordRep = Limb Word#
- render :: Limb -> String
- and# :: Limb -> Limb -> Limb
- or# :: Limb -> Limb -> Limb
- not# :: Limb -> Limb
- xor# :: Limb -> Limb -> Limb
- bits# :: Limb -> Int
- shl# :: Limb -> Int# -> Limb
- shl1# :: Limb -> (# Limb, Limb #)
- shr# :: Limb -> Int# -> Limb
- shr1# :: Limb -> (# Limb, Limb #)
- eq# :: Limb -> Limb -> Choice
- ne# :: Limb -> Limb -> Choice
- eq_vartime# :: Limb -> Limb -> Bool
- ne_vartime# :: Limb -> Limb -> Bool
- nonzero# :: Limb -> Choice
- lt# :: Limb -> Limb -> Choice
- gt# :: Limb -> Limb -> Choice
- select# :: Limb -> Limb -> Choice -> Limb
- cswap# :: Limb -> Limb -> Choice -> (# Limb, Limb #)
- neg# :: Limb -> Limb
- add_o# :: Limb -> Limb -> (# Limb, Limb #)
- add_c# :: Limb -> Limb -> Limb -> (# Limb, Limb #)
- add_w# :: Limb -> Limb -> Limb
- add_s# :: Limb -> Limb -> Limb
- sub_b# :: Limb -> Limb -> Limb -> (# Limb, Limb #)
- sub_w# :: Limb -> Limb -> Limb
- sub_s# :: Limb -> Limb -> Limb
- mul_c# :: Limb -> Limb -> (# Limb, Limb #)
- mul_w# :: Limb -> Limb -> Limb
- mul_s# :: Limb -> Limb -> Limb
- mac# :: Limb -> Limb -> Limb -> Limb -> (# Limb, Limb #)
Limb
Bit manipulation and representation
Number of bits required to represent this limb.
Comparison
Selection
Return a if c is truthy, otherwise return b.
Return (# b, a #) if c is truthy, otherwise return (# a, b #).
Negation
Arithmetic
Overflowing addition, computing augend + addend, returning the sum and carry.
Carrying addition, computing augend + addend + carry, returning the sum and new carry.
Wrapping addition, computing augend + addend, returning the sum (discarding overflow).
add_s# :: Limb -> Limb -> Limb Source #
Saturating addition, computing augend + addend, returning the sum (clamping to the maximum representable value in the case of overflow).
Arguments
| :: Limb | minuend |
| -> Limb | subtrahend |
| -> Limb | borrow |
| -> (# Limb, Limb #) | (# difference, new borrow #) |
Borrowing subtraction, computing minuend - (subtrahend + borrow), returning the difference and new borrow mask.
Wrapping subtraction, computing minuend - subtrahend, returning the difference (and discarding underflow).
Saturating subtraction, computing minuend - subtrahend, returning the difference (and clamping to zero in the case of underflow).
Widening multiplication, returning low and high words of the product.
Wrapping multiplication, returning only the low word of the product.
Saturating multiplication, returning only the low word of the product, and clamping to the maximum value in the case of overflow.