Epstein Zeta Library 0.6.2
Calculates the Epstein Zeta function
Loading...
Searching...
No Matches
Classes | Macros | Functions
hpdyad.h File Reference

High-precision dyadic number operations. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  hpdyad_t
 Fixed-size high-precision dyadic number (hpdyad) with separate sign and binary exponent. More...
 

Macros

#define HPDYAD_MAX_LIMBS   32
 Maximum number of 32-bit limbs in fixed-size representation (1024 bits total).
 

Functions

unsigned ctz64 (unsigned long long x)
 Count trailing zero bits in a 64-bit unsigned integer.
 
int msb32 (unsigned int x)
 Find index of most significant bit in a 32-bit unsigned integer.
 
void hpdyad_set_ull (hpdyad_t *a, unsigned long long x, signed char sign)
 Initialize hpdyad from unsigned long long with sign.
 
void hpdyad_normalize (hpdyad_t *a)
 Normalize hpdyad: trim leading zeros and left-shift mantissa so MSB of top limb is 1.
 
void hpdyad_mul (hpdyad_t *out, const hpdyad_t *a, const hpdyad_t *b)
 Multiply two high precision dyadic numbers (hpdyad's): out = a * b.
 
void hpdyad_shr_bits_sticky (hpdyad_t *dst, const hpdyad_t *src, unsigned int bits)
 Right-shift mantissa with sticky bit (value-preserving)
 
void hpdyad_shl_bits (hpdyad_t *dst, const hpdyad_t *src, int bits)
 Left-shift mantissa by specified number of bits (value-preserving)
 
void hpdyad_add (hpdyad_t *out, const hpdyad_t *a, const hpdyad_t *b)
 Add two high precision dyadic numbers (hpdyad's): out = a + b.
 
double hpdyad_to_double (const hpdyad_t *a)
 Convert hpdyad to double with round-to-nearest-even.
 

Detailed Description

High-precision dyadic number operations.

Function Documentation

◆ ctz64()

unsigned ctz64 ( unsigned long long x)

Count trailing zero bits in a 64-bit unsigned integer.

Parameters
[in]xinput value
Returns
number of trailing zeros (0..63); returns 64 if x == 0

◆ hpdyad_add()

void hpdyad_add ( hpdyad_t * out,
const hpdyad_t * a,
const hpdyad_t * b )

Add two high precision dyadic numbers (hpdyad's): out = a + b.

Parameters
[out]outresult (supports aliasing)
[in]afirst operand
[in]bsecond operand

◆ hpdyad_mul()

void hpdyad_mul ( hpdyad_t * out,
const hpdyad_t * a,
const hpdyad_t * b )

Multiply two high precision dyadic numbers (hpdyad's): out = a * b.

Parameters
[out]outresult (may alias a or b)
[in]afirst operand
[in]bsecond operand

◆ hpdyad_normalize()

void hpdyad_normalize ( hpdyad_t * a)

Normalize hpdyad: trim leading zeros and left-shift mantissa so MSB of top limb is 1.

Parameters
[in,out]apointer to hpdyad to normalize
Returns
void

◆ hpdyad_set_ull()

void hpdyad_set_ull ( hpdyad_t * a,
unsigned long long x,
signed char sign )

Initialize hpdyad from unsigned long long with sign.

Parameters
[out]adestination hpdyad
[in]xunsigned integer value
[in]sign+1 or -1

◆ hpdyad_shl_bits()

void hpdyad_shl_bits ( hpdyad_t * dst,
const hpdyad_t * src,
int bits )

Left-shift mantissa by specified number of bits (value-preserving)

Parameters
[out]dstdestination hpdyad
[in]srcsource hpdyad
[in]bitsnumber of bits to shift left
Returns
void

◆ hpdyad_shr_bits_sticky()

void hpdyad_shr_bits_sticky ( hpdyad_t * dst,
const hpdyad_t * src,
unsigned int bits )

Right-shift mantissa with sticky bit (value-preserving)

Shifts mantissa right by bits, increments exp2 by bits to preserve value. Any 1-bit shifted out ORs into bit 0 (sticky). Does NOT normalize.

Parameters
[out]dstdestination hpdyad
[in]srcsource hpdyad
[in]bitsnumber of bits to shift right

◆ hpdyad_to_double()

double hpdyad_to_double ( const hpdyad_t * a)

Convert hpdyad to double with round-to-nearest-even.

Parameters
[in]apointer to normalized hpdyad
Returns
closest double representation; ±DBL_MAX on overflow

◆ msb32()

int msb32 ( unsigned int x)

Find index of most significant bit in a 32-bit unsigned integer.

Parameters
[in]xinput value
Returns
bit index 0..31; returns 0 for x == 0 (defensive fallback)