Skip to main content
Skip table of contents

64-bit handling functions

This page applies to Harlequin v13.1r0 and later; and to Harlequin MultiRIP but not Harlequin Core

The plugin library provides the following types of functions for handling 64‐bit integers:

Data type conversions

Comparison functions

Unary operations

Binary operations

Binary mixed-type operations

Data type conversions

Convert 32-bit integers to 64-bit

The following functions convert a uint32 or int32 , respectively, into a Hq32x2 or HqU32x2 . HqU32x2FromInt32 returns TRUE if the i32 value is positive (and therefore in range); FALSE if negative (in which case, *p32x2 is unchanged):

void Hq32x2FromUint32(Hq32x2 *p32x2, uint32 i32); void Hq32x2FromInt32(Hq32x2 *p32x2, int32 i32); void HqU32x2FromUint32(HqU32x2 *p32x2, uint32 i32); int32 HqU32x2FromInt32(HqU32x2 *p32x2, int32 i32);

Convert 64-bit integers to 32-bit

The following functions convert a Hq32x2 or HqU32x2 into a uint32 or int32 , respectively. They return TRUE upon success, or FALSE if the value was out of range for its destination, in which case the destination variable is unchanged:

TEXT
    int32 Hq32x2ToUint32(Hq32x2 *p32x2, uint32 *pReturn); int32 Hq32x2ToInt32(Hq32x2 *p32x2, int32 *pReturn); int32 HqU32x2ToUint32(HqU32x2 *p32x2, uint32 *pReturn);
    int32 HqU32x2ToInt32(HqU32x2 *p32x2, int32 *pReturn);

Convert 64-bit integers to 32-bit, returning the limit value if out of range

The following functions return the unsigned or signed, respectively, 32‐bit value stored in the Hq32x2

or HqU32x2 , or the limit value if out of range.

uint32 Hq32x2BoundToUint32(Hq32x2 *pU32x2); int32 Hq32x2BoundToInt32(Hq32x2 *p32x2); uint32 HqU32x2BoundToUint32(HqU32x2 *pU32x2); int32 HqU32x2BoundToInt32(HqU32x2 *pU32x2);

Convert 64-bit integers to 32-bit, returning the limit value if out of range and asserting

The following functions return the unsigned or signed, respectively, 32‐bit value stored in the Hq32x2

or HqU32x2 , or the limit value if out of range and raising an assert in an asserted build.

int32 Hq32x2AssertToInt32(const Hq32x2 *p32x2); uint32 Hq32x2AssertToUint32(const Hq32x2 *p32x2); int32 HqU32x2AssertToInt32(const HqU32x2 *pU32x2); uint32 HqU32x2AssertToUint32(const HqU32x2 *pU32x2);

Convert a double into a 64-bit integer

The following functions store a value specified by a double variable in a Hq32x2 or HqU32x2 . The fractional part is dropped (round to zero), and if the original value is out of the range of the destination variable, the limit value is stored:

void Hq32x2FromDouble(Hq32x2 *p32x2, double dbl); void HqU32x2FromDouble(HqU32x2 *pU32x2, double dbl);

Note: No indication of the fact that the double is out of range is given.

The following functions return the double equivalent of the Hq32x2 or HqU32x2 value:

double Hq32x2ToDouble(Hq32x2 *p32x2); double HqU32x2ToDouble(HqU32x2 *pU32x2);

Note: These conversions may result in loss of precision for large positive or negative values. There is

no indication of loss of precision.

Convert between Hq32x2 and HqU32x2 values

The following functions convert between Hq32x2 and HqU32x2 values. They return TRUE if the conversion was successful, or FALSE if the source value is out of range for the target variable's type (in which case, the target value is unchanged).

int32 Hq32x2FromU32x2(Hq32x2 *p32x2, HqU32x2 *pU32x2); int32 HqU32x2From32x2(HqU32x2 *pU32x2, Hq32x2 *p32x2);

Conversion between size_t and 64-bit integers

The following functions store the value specified by size_t into the Hq32x2 or HqU32x2 parameter:

void Hq32x2FromSize_t(Hq32x2 *p32x2, size_t sizet); void HqU32x2FromSize_t(HqU32x2 *pU32x2, size_t sizet);

The following functions convert as Hq32x2 or HqU32x2 parameter into a size_t . They return TRUE if the

value is in rnage for a size_t variable, else FALSE :

HqBool Hq32x2ToSize_t(const Hq32x2 *p32x2, size_t *sizet); HqBool HqU32x2ToSize_t(const HqU32x2 *pU32x2, size_t *sizet);

Conversion between ptrdiff_t and 64-bit integers

The following function stores the value specified by ptrdiff into the Hq32x2 parameter:

void Hq32x2FromPtrdiff_t(Hq32x2 *p32x2, ptrdiff_t ptrdiff);

Comparison functions

These functions test 64‐bit integers for various conditions:

Test for zero

The following functions test whether or not the value of the tested variable is zero. The functions return TRUE if the Hq32x2 or HqU32x2 value is zero; otherwise, they return FALSE :

int32 Hq32x2IsZero(Hq32x2 *p32x2); int32 HqU32x2IsZero(HqU32x2 *pU32x2);

Determine the sign of a signed 64-bit integer

The following functions indicate the sign of the value passed into the function as an Hq32x2 or an

HqU32x2 parameter:

int32 Hq32x2Sign(Hq32x2 *p32x2); int32 HqU32x2Sign(HqU32x2 *pU32x2);

The functions return ‐1 if the parameter is negative, zero if the parameter is zero or +1 if the parameter

is positive.

Unary operations

The following functions set a Hq32x2 or HqU32x2 variable to the largest value it can hold:

void Hq32x2Max(Hq32x2 *p32x2); void HqU32x2Max(HqU32x2 *pU32x2);

The following macros can be used as static initializers for Hq32x2 and HqU32x2 variables:

HQ32X2_INIT_ZERO

initialize Hq32x2 and HqU32x2 with zero.

HQ32X2_INIT_MAX

initialize Hq32x2 with largest positive value.

HQ32X2_INIT_MIN

initialize Hq32x2 with largest negative value.

HQU32X2_INIT_MAX

initialize HqU32x2 with largest positive value.

Binary operations

These functions provide basic mathematical operations on 64‐bit integers:

Add two 64-bit integers

The following two functions add the values passed in via the p32x2... /pU32x2... parameters and write the sum to p...Result .

TEXT
    void Hq32x2Add(
              Hq32x2 *p32x2Result, Hq32x2 *p32x2A, Hq32x2 *p32x2B);
    void HqU32x2Add(
              HqU32x2 *pU32x2Result, HqU32x2 *pU32x2A, HqU32x2 *pU32x2B);

Note: No warning is given if the sum is greater than can be held by a 64-bit integer.

Subtract one 64-bit integer from another

The following two functions subtract p...B from p..A and write the result to p...Result :

TEXT
    void Hq32x2Subtract(
              Hq32x2 *p32x2Result, Hq32x2 *p32x2A, Hq32x2 *p32x2B);
    void HqU32x2Subtract(
              HqU32x2 *pU32x2Result, HqU32x2 *pU32x2A, HqU32x2 *pU32x2B);

Note: No warning is given if the result is outside the bounds of a 64-bit integer.

Compare the values of two 64-bit integers

The following two functions compare the values of two Hq32x2 or HqU32x2 variables by subtracting p...B from p...A and returning the sign of the result. The functions return ‐1 if the parameter is negative, zero if the parameter is zero or +1 if the parameter is positive:

int32 Hq32x2Compare(Hq32x2 *p32x2A, Hq32x2 *p32x2B); int32 HqU32x2Compare(HqU32x2 *pU32x2A, HqU32x2 * pU32x2);

Note: No warning is given if the subtraction operation results in a value which cannot be held by a 64

bit integer.

Binary mixed-type operations

The following functions allow addition, subtraction and comparison operations to be performed on Hq32x2 and HqU32x2 variables using int32 or uint32 operands. The operation of the functions is as described in Binary operations .

Add a uint32 to a 64-bit integer

This function adds a uint32 value to p...A , and writes the sum to p...Result :

TEXT
    void Hq32x2AddUint32(
              Hq32x2 *p32x2Result, Hq32x2 *p32x2A, uint32 ui32);
    void HqU32x2AddUint32(
              HqU32x2 *pU32x2Result, HqU32x2 *pU32x2A, uint32 ui32);

Add an int32 to a 64-bit integer

This function adds an int32 value to p...A , and writes the sum to p...Result :

TEXT
    void Hq32x2AddInt32(
              Hq32x2 *p32x2Result, Hq32x2 *p32x2A, int32 i32);
    void HqU32x2AddInt32(
              HqU32x2 *pU32x2Result, HqU32x2 *pU32x2A, int32 i32);

Subtract a uint32 from a 64-bit integer

This function subtracts a uint32 value from p...A , and writes the sum to p...Result :

TEXT
    void Hq32x2SubtractUint32(
              Hq32x2 *p32x2Result, Hq32x2 *p32x2A, uint32 ui32);
    void HqU32x2SubtractUint32(
              HqU32x2 *pU32x2Result, HqU32x2 *pU32x2A, uint32 ui32);

Subtract an int32 from a 64-bit integer

This function subtracts an int32 value from p...A , and writes the sum to p...Result :

TEXT
    void Hq32x2SubtractInt32(
              Hq32x2 *p32x2Result, Hq32x2 *p32x2A, int32 i32);
    void HqU32x2SubtractInt32(
              HqU32x2 *pU32x2Result, HqU32x2 *pU32x2A, int32 i32);

Compare the value of an unsigned 32-bit integer with a 64-bit integer

The following two functions compare the value of an unsigned 32‐bit integer with an Hq32x2 or HqU32x2 variable. The algorithm is that the function subtracts the uint32 variable from the Hq[U]32x2 variable and returns the sign of the result. The functions return ‐1 if the parameter is negative, zero if the parameter is zero or +1 if the parameter is positive:

TEXT
    int32 Hq32x2CompareUint32(
              Hq32x2 * p32x2A, uint32 ui32);
    int32 HqU32x2CompareUint32(
              HqU32x2 *pU32x2, uint32 ui32);

Compare the value of a signed 32-bit integer with a 64-bit integer

The following function compares the value of a signed 32‐bit integer with an Hq32x2 variable. The algorithm is the same as that listed above. The functions return ‐1 if the parameter is negative, zero if the parameter is zero or +1 if the parameter is positive:

TEXT
    int32 Hq32x2CompareInt32(
              Hq32x2 *p32x2A, int32 i32);

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.