Compatibility support for 64-bit integer types. More...
#include "hqncall.h"
Data Structures | |
struct | Hq32x2 |
Signed 64 bit integer, represented as a 2s complement pair. More... | |
struct | HqU32x2 |
Unsigned 64 bit integer, represented as a 2s complement pair. More... | |
Macros | |
#define | Hq32x2FromInt32(p32x2, i32) |
Fill in a 64-bit signed integer from a 32-bit signed integer. | |
#define | HqU32x2FromInt32(pU32x2, i32) |
Fill in a 64-bit unsigned integer from a 32-bit signed integer, asserting that the 32-bit integer is not negative. | |
#define | Hq32x2FromUint32(p32x2, ui32) |
Fill in a 64-bit signed integer from a 32-bit unsigned integer. | |
#define | HqU32x2FromUint32(pU32x2, ui32) |
Fill in a 64-bit unsigned integer from a 32-bit unsigned integer. | |
#define | HQ32X2_INIT_ZERO { 0, 0 } |
Static or auto zero-value initialiser for Hq32x2 and HqU32x2. | |
#define | HQ32X2_INIT_MONE { MAXUINT32, -1 } |
Static or auto -1-value initialiser for Hq32x2. | |
#define | HQ32X2_INIT_MAX { MAXUINT32, MAXINT32 } |
Static or auto maximum-value initialiser for Hq32x2. | |
#define | HQ32X2_INIT_MIN { 0, MININT32 } |
Static or auto minimum-value initialiser for Hq32x2. | |
#define | HQU32X2_INIT_MAX { MAXUINT32, MAXUINT32 } |
Static or auto maximum-value initialiser for HqU32x2. | |
#define | Hq32x2Max(p32x2) |
Fill in a 64-bit signed integer with its maximum possible value. | |
#define | HqU32x2Max(pU32x2) |
Fill in a 64-bit unsigned integer with its maximum possible value. | |
#define | Hq32x2IsZero(p32x2) ((p32x2)->high == 0 && (p32x2)->low == 0) |
A predicate to tell if a 64-bit signed integer's value is zero. | |
#define | HqU32x2IsZero(pU32x2) Hq32x2IsZero( pU32x2 ) |
A predicate to tell if a 64-bit unsigned integer's value is zero. | |
#define | HqU32x2From32x2(pU32x2, p32x2) |
Fill in a 64-bit unsigned integer from a 64-bit signed integer, asserting that its value is not negative. | |
#define | Hq32x2FromU32x2(p32x2, pU32x2) |
Fill in a 64-bit signed integer from a 64-bit unsigned integer, asserting that its value is within range. | |
#define | Hq32x2ToInt64(p32x2, pi64) |
Convert a 64-bit signed 32x2 integer to a native 64-bit signed integer. | |
#define | HqU32x2ToUint64(pU32x2, pu64) |
Convert a 64-bit unsigned 32x2 integer to a native 64-bit unsigned integer. | |
Typedefs | |
typedef struct Hq32x2 | Hq32x2 |
Signed 64 bit integer, represented as a 2s complement pair. | |
typedef struct HqU32x2 | HqU32x2 |
Unsigned 64 bit integer, represented as a 2s complement pair. | |
Functions | |
HqBool | Hq32x2ToInt32 (const Hq32x2 *p32x2, int32 *pReturn) |
Convert a 64-bit signed integer to a 32-bit signed integer. More... | |
HqBool | HqU32x2ToInt32 (const HqU32x2 *pU32x2, int32 *pReturn) |
Convert a 64-bit unsigned integer to a 32-bit signed integer. More... | |
HqBool | Hq32x2ToUint32 (const Hq32x2 *p32x2, uint32 *pReturn) |
Convert a 64-bit signed integer to a 32-bit unsigned integer. More... | |
HqBool | HqU32x2ToUint32 (const HqU32x2 *pU32x2, uint32 *pReturn) |
Convert a 64-bit unsigned integer to a 32-bit unsigned integer. More... | |
int32 | Hq32x2BoundToInt32 (const Hq32x2 *p32x2) |
Convert a 64-bit signed integer to a 32-bit signed integer, limiting to the range of the 32-bit integer. More... | |
int32 | HqU32x2BoundToInt32 (const HqU32x2 *pU32x2) |
Convert a 64-bit unsigned integer to a 32-bit signed integer, limiting to the range of the 32-bit integer. More... | |
uint32 | Hq32x2BoundToUint32 (const Hq32x2 *p32x2) |
Convert a 64-bit signed integer to a 32-bit unsigned integer, limiting to the range of the 32-bit integer. More... | |
uint32 | HqU32x2BoundToUint32 (const HqU32x2 *pU32x2) |
Convert a 64-bit unsigned integer to a 32-bit unsigned integer, limiting to the range of the 32-bit integer. More... | |
int32 | Hq32x2AssertToInt32 (const Hq32x2 *p32x2) |
Convert a 64-bit signed integer to a 32-bit signed integer, limiting to the range of the 32-bit integer. More... | |
int32 | HqU32x2AssertToInt32 (const HqU32x2 *pU32x2) |
Convert a 64-bit unsigned integer to a 32-bit signed integer, limiting to the range of the 32-bit integer. More... | |
uint32 | Hq32x2AssertToUint32 (const Hq32x2 *p32x2) |
Convert a 64-bit signed integer to a 32-bit unsigned integer, limiting to the range of the 32-bit integer. More... | |
uint32 | HqU32x2AssertToUint32 (const HqU32x2 *pU32x2) |
Convert a 64-bit unsigned integer to a 32-bit unsigned integer, limiting to the range of the 32-bit integer. More... | |
void | Hq32x2FromPtrdiff_t (Hq32x2 *p32x2, ptrdiff_t ptrdiff) |
Fill in a 64-bit signed integer from the difference between two pointers. More... | |
void | Hq32x2FromSize_t (Hq32x2 *p32x2, size_t sizet) |
Fill in a 64-bit signed integer from an integral value representing the result of the sizeof() operator. More... | |
HqBool | Hq32x2ToSize_t (const Hq32x2 *p32x2, size_t *sizet) |
Convert a 64-bit signed integer to an unsigned value sufficient to represent the size of an object. More... | |
void | HqU32x2FromSize_t (HqU32x2 *pU32x2, size_t sizet) |
Fill in a 64-bit unsigned integer from an integral value representing the result of the sizeof() operator. More... | |
HqBool | HqU32x2ToSize_t (const HqU32x2 *pU32x2, size_t *sizet) |
Convert a 64-bit unsigned integer to an unsigned value sufficient to represent the size of an object. More... | |
void | Hq32x2FromDouble (Hq32x2 *p32x2, double dbl) |
Fill in a 64-bit signed integer from a double-precision floating point value. The double is asserted to be in the range of an Hq32x2. More... | |
void | HqU32x2FromDouble (HqU32x2 *pU32x2, double dbl) |
Fill in a 64-bit unsigned integer from a double-precision floating point value. The double is asserted to be in the range of an HqU32x2. More... | |
double | Hq32x2ToDouble (const Hq32x2 *p32x2) |
Convert a 64-bit signed integer to a double-precision floating point value. Precision may be silently reduced, depending on the magnitude of the 64-bit integral value. More... | |
double | HqU32x2ToDouble (const HqU32x2 *pU32x2) |
Convert a 64-bit unsigned integer to a double-precision floating point value. Precision may be silently reduced, depending on the magnitude of the 64-bit integral value. More... | |
int32 | Hq32x2Sign (const Hq32x2 *p32x2) |
Return the sign of a 64-bit signed integer. More... | |
uint32 | HqU32x2Sign (const HqU32x2 *pU32x2) |
Return the sign of a 64-bit unsigned integer. More... | |
void | Hq32x2Add (Hq32x2 *p32x2Result, const Hq32x2 *p32x2A, const Hq32x2 *p32x2B) |
Add two signed 64-bit numbers, storing the sum into a third. More... | |
void | HqU32x2Add (HqU32x2 *pU32x2Result, const HqU32x2 *pU32x2A, const HqU32x2 *pU32x2B) |
Add two unsigned 64-bit numbers, storing the sum into a third. More... | |
void | Hq32x2Subtract (Hq32x2 *p32x2Result, const Hq32x2 *p32x2A, const Hq32x2 *p32x2B) |
Subtract two signed 64-bit numbers, storing the difference into a third. More... | |
void | HqU32x2Subtract (HqU32x2 *pU32x2Result, const HqU32x2 *pU32x2A, const HqU32x2 *pU32x2B) |
Subtract two unsigned 64-bit numbers, storing the difference into a third. More... | |
int32 | Hq32x2Compare (const Hq32x2 *p32x2A, const Hq32x2 *p32x2B) |
Compare two 64-bit signed integers. More... | |
int32 | HqU32x2Compare (const HqU32x2 *pU32x2A, const HqU32x2 *pU32x2B) |
Compare two 64-bit unsigned integers. More... | |
void | Hq32x2AddUint32 (Hq32x2 *p32x2Result, const Hq32x2 *p32x2A, uint32 ui32) |
Add an unsigned 32-bit integer to a signed 64-bit integer, storing the sum into a signed 64-bit integer. More... | |
void | HqU32x2AddUint32 (HqU32x2 *pU32x2Result, const HqU32x2 *pU32x2A, uint32 ui32) |
Add an unsigned 32-bit integer to an unsigned 64-bit integer, storing the sum into an unsigned 64-bit integer. More... | |
void | Hq32x2SubtractUint32 (Hq32x2 *p32x2Result, const Hq32x2 *p32x2A, uint32 ui32) |
Subtract an unsigned 32-bit integer from a signed 64-bit integer, storing the sum into a signed 64-bit integer. More... | |
void | HqU32x2SubtractUint32 (HqU32x2 *pU32x2Result, const HqU32x2 *pU32x2A, uint32 ui32) |
Subtract an unsigned 32-bit integer from an unsigned 64-bit integer, storing the sum into an unsigned 64-bit integer. More... | |
int32 | Hq32x2CompareUint32 (const Hq32x2 *p32x2A, uint32 ui32) |
Compare an unsigned 32-bit integer to a signed 64-bit integer. More... | |
int32 | HqU32x2CompareUint32 (const HqU32x2 *pU32x2A, uint32 ui32) |
Compare an unsigned 32-bit integer to an unsigned 64-bit integer. More... | |
void | Hq32x2AddInt32 (Hq32x2 *p32x2Result, const Hq32x2 *p32x2A, int32 i32) |
Add a signed 32-bit integer to a signed 64-bit integer, storing the sum into a signed 64-bit integer. More... | |
void | Hq32x2SubtractInt32 (Hq32x2 *p32x2Result, const Hq32x2 *p32x2A, int32 i32) |
Subtract a signed 32-bit integer from a signed 64-bit integer, storing the sum into a signed 64-bit integer. More... | |
int32 | Hq32x2CompareInt32 (const Hq32x2 *p32x2A, int32 i32) |
Compare a signed 32-bit integer to a signed 64-bit integer. More... | |
HqBool | Hq32x2DivRemUint32 (Hq32x2 *result, uint32 *remainder, const Hq32x2 *p32x2, uint32 divisor) |
Divide an Hq32x2 by an unsigned 32 bit integer, getting an Hq32x2 result and optional remainder. More... | |
HqBool | Hq32x2MultUint32Uint32 (Hq32x2 *result, uint32 ui32A, uint32 ui32B) |
Multiply two unsigned 32-bit integers together, storing the product into a signed 64-bit integer. More... | |
Compatibility support for 64-bit integer types.
Hq32x2 is a 64-bit signed integer type. HqU32x2 is an unsigned 64 bit type. These types are used in interfaces which tend not to be performance-critical, such as file lengths or positions. A set of initialisers, type conversions to and from native 32-bit and 64-bit integers, and basic arithmetic and comparison operations are provided.
Copyright (C) 2023 Global Graphics Software Ltd. All rights reserved. This source code contains the confidential and trade secret information of Global Graphics Software Ltd. It may not be used, copied or distributed for any reason except as set forth in the applicable Global Graphics license agreement.
Add two signed 64-bit numbers, storing the sum into a third.
[in] | p32x2Result | A pointer where the sum of the two inputs is stored. This pointer may be the same as either or both of the inputs. |
[in] | p32x2A | A pointer to the first operand. |
[in] | p32x2B | A pointer to the second operand. |
Add a signed 32-bit integer to a signed 64-bit integer, storing the sum into a signed 64-bit integer.
[in] | p32x2Result | A pointer where the sum of the two inputs is stored. This pointer may be the same as the pointer to the first operand. |
[in] | p32x2A | A pointer to the first operand. |
[in] | i32 | A 32-bit signed integer to be added to the first operand. |
Add an unsigned 32-bit integer to a signed 64-bit integer, storing the sum into a signed 64-bit integer.
[in] | p32x2Result | A pointer where the sum of the two inputs is stored. This pointer may be the same as the pointer to the first operand. |
[in] | p32x2A | A pointer to the first operand. |
[in] | ui32 | A 32-bit unsigned integer to be added to the first operand. |
Convert a 64-bit signed integer to a 32-bit signed integer, limiting to the range of the 32-bit integer.
[in] | p32x2 | The 64-bit signed integer to convert. |
Convert a 64-bit signed integer to a 32-bit unsigned integer, limiting to the range of the 32-bit integer.
[in] | p32x2 | The 64-bit signed integer to convert. |
Convert a 64-bit signed integer to a 32-bit signed integer, limiting to the range of the 32-bit integer.
[in] | p32x2 | The 64-bit signed integer to convert. |
Convert a 64-bit signed integer to a 32-bit unsigned integer, limiting to the range of the 32-bit integer.
[in] | p32x2 | The 64-bit signed integer to convert. |
Compare two 64-bit signed integers.
[in] | p32x2A | A pointer to the first operand. |
[in] | p32x2B | A pointer to the second operand. |
-1 | Returned if the first operand is less than the second. |
0 | Returned if the operands have the same value. |
1 | Returned if the first operand is greater than the second. |
Compare a signed 32-bit integer to a signed 64-bit integer.
[in] | p32x2A | A pointer to the first operand. |
[in] | i32 | A 32-bit signed integer to be compared with the first operand. |
-1 | Returned if the first operand is less than the second. |
0 | Returned if the operands have the same value. |
1 | Returned if the first operand is greater than the second. |
Compare an unsigned 32-bit integer to a signed 64-bit integer.
[in] | p32x2A | A pointer to the first operand. |
[in] | ui32 | A 32-bit unsigned integer to be compared with the first operand. |
-1 | Returned if the first operand is less than the second. |
0 | Returned if the operands have the same value. |
1 | Returned if the first operand is greater than the second. |
HqBool Hq32x2DivRemUint32 | ( | Hq32x2 * | result, |
uint32 * | remainder, | ||
const Hq32x2 * | p32x2, | ||
uint32 | divisor | ||
) |
Divide an Hq32x2 by an unsigned 32 bit integer, getting an Hq32x2 result and optional remainder.
[out] | result | A location to store the result of p32x2/divisor, truncated towards zero. |
[out] | remainder | An optional location to store the remainder of p32x2/divisor. |
[in] | p32x2 | A large number to divide |
[in] | divisor | A positive divisor to divide p32x2 by. |
TRUE | The division succeeded, and the result and remainder are stored in the locations provided. |
FALSE | The divisor was zero, or the dividend was negative and remainder is non-NULL; this function follows C division which truncates towards zero, so the remainder of dividing a negative divisor will be negative or zero. If the remainder pointer is NULL, then division of negative dividends is supported. |
void Hq32x2FromDouble | ( | Hq32x2 * | p32x2, |
double | dbl | ||
) |
Fill in a 64-bit signed integer from a double-precision floating point value. The double is asserted to be in the range of an Hq32x2.
[out] | p32x2 | A pointer to the 64-bit signed integer filled in with the truncated double value. |
[in] | dbl | A double precision floating point value to be truncated and converted to a signed 64-bit integral integer. |
void Hq32x2FromPtrdiff_t | ( | Hq32x2 * | p32x2, |
ptrdiff_t | ptrdiff | ||
) |
Fill in a 64-bit signed integer from the difference between two pointers.
[out] | p32x2 | A pointer to the 64-bit signed integer filled in with the pointer difference value. |
[in] | ptrdiff | An integral value, representing the difference between two pointers. |
void Hq32x2FromSize_t | ( | Hq32x2 * | p32x2, |
size_t | sizet | ||
) |
Fill in a 64-bit signed integer from an integral value representing the result of the sizeof()
operator.
[out] | p32x2 | A pointer to the 64-bit signed integer filled in with the pointer difference value. |
[in] | sizet | An integral value, representing the maximum size of an object. |
Multiply two unsigned 32-bit integers together, storing the product into a signed 64-bit integer.
[in] | result | A pointer where the product of the two inputs is stored. |
[in] | ui32A | The first operand. |
[in] | ui32B | The second operand. |
Return the sign of a 64-bit signed integer.
[in] | p32x2 | A pointer to the 64-bit signed integer to be tested. |
-1 | Returned if the value stored at p32x2 is negative. |
0 | Returned if the value stored at p32x2 is zero. |
1 | Returned if the value stored at p32x2 is positive. |
Subtract two signed 64-bit numbers, storing the difference into a third.
[in] | p32x2Result | A pointer where the difference of the two inputs is stored. This pointer may be the same as either or both of the inputs. |
[in] | p32x2A | A pointer to the first operand. |
[in] | p32x2B | A pointer to the second operand. |
Subtract a signed 32-bit integer from a signed 64-bit integer, storing the sum into a signed 64-bit integer.
[in] | p32x2Result | A pointer where the difference of the two inputs is stored. This pointer may be the same as the pointer to the first operand. |
[in] | p32x2A | A pointer to the first operand. |
[in] | i32 | A 32-bit signed integer to be subtracted from the first operand. |
Subtract an unsigned 32-bit integer from a signed 64-bit integer, storing the sum into a signed 64-bit integer.
[in] | p32x2Result | A pointer where the difference of the two inputs is stored. This pointer may be the same as the pointer to the first operand. |
[in] | p32x2A | A pointer to the first operand. |
[in] | ui32 | A 32-bit unsigned integer to be subtracted from the first operand. |
double Hq32x2ToDouble | ( | const Hq32x2 * | p32x2 | ) |
Convert a 64-bit signed integer to a double-precision floating point value. Precision may be silently reduced, depending on the magnitude of the 64-bit integral value.
[in] | p32x2 | A pointer to the 64-bit signed integer to be converted to double. |
Convert a 64-bit signed integer to a 32-bit signed integer.
[in] | p32x2 | The 64-bit signed integer to convert. |
[out] | pReturn | A pointer to the converted integer. |
TRUE | Returned if the 64-bit integer's value was in range of the 32-bit integer. |
FALSE | Returned if the 64-bit integer's value was out of range of the 32-bit integer. The value stored in pReturn is not modified in this case. |
Convert a 64-bit signed integer to an unsigned value sufficient to represent the size of an object.
[in] | p32x2 | The 64-bit unsigned integer to convert. |
[out] | sizet | A pointer to the converted integer. |
TRUE | Returned if the 64-bit integer's value was in range of size_t . |
FALSE | Returned if the 64-bit integer's value was out of range of size_t . |
Convert a 64-bit signed integer to a 32-bit unsigned integer.
[in] | p32x2 | The 64-bit signed integer to convert. |
[out] | pReturn | A pointer to the converted integer. |
TRUE | Returned if the 64-bit integer's value was in range of the 32-bit integer. |
FALSE | Returned if the 64-bit integer's value was out of range of the 32-bit integer. The value stored in pReturn is not modified in this case. |
Add two unsigned 64-bit numbers, storing the sum into a third.
[in] | pU32x2Result | A pointer where the sum of the two inputs is stored. This pointer may be the same as either or both of the inputs. |
[in] | pU32x2A | A pointer to the first operand. |
[in] | pU32x2B | A pointer to the second operand. |
Add an unsigned 32-bit integer to an unsigned 64-bit integer, storing the sum into an unsigned 64-bit integer.
[in] | pU32x2Result | A pointer where the sum of the two inputs is stored. This pointer may be the same as the pointer to the first operand. |
[in] | pU32x2A | A pointer to the first operand. |
[in] | ui32 | A 32-bit unsigned integer to be added to the first operand. |
Convert a 64-bit unsigned integer to a 32-bit signed integer, limiting to the range of the 32-bit integer.
[in] | pU32x2 | The 64-bit unsigned integer to convert. |
Convert a 64-bit unsigned integer to a 32-bit unsigned integer, limiting to the range of the 32-bit integer.
[in] | pU32x2 | The 64-bit unsigned integer to convert. |
Convert a 64-bit unsigned integer to a 32-bit signed integer, limiting to the range of the 32-bit integer.
[in] | pU32x2 | The 64-bit unsigned integer to convert. |
Convert a 64-bit unsigned integer to a 32-bit unsigned integer, limiting to the range of the 32-bit integer.
[in] | pU32x2 | The 64-bit unsigned integer to convert. |
Compare two 64-bit unsigned integers.
[in] | pU32x2A | A pointer to the first operand. |
[in] | pU32x2B | A pointer to the second operand. |
-1 | Returned if the first operand is less than the second. |
0 | Returned if the operands have the same value. |
1 | Returned if the first operand is greater than the second. |
Compare an unsigned 32-bit integer to an unsigned 64-bit integer.
[in] | pU32x2A | A pointer to the first operand. |
[in] | ui32 | A 32-bit unsigned integer to be compared with the first operand. |
-1 | Returned if the first operand is less than the second. |
0 | Returned if the operands have the same value. |
1 | Returned if the first operand is greater than the second. |
void HqU32x2FromDouble | ( | HqU32x2 * | pU32x2, |
double | dbl | ||
) |
Fill in a 64-bit unsigned integer from a double-precision floating point value. The double is asserted to be in the range of an HqU32x2.
[out] | pU32x2 | A pointer to the 64-bit unsigned integer filled in with the truncated double value. |
[in] | dbl | A double precision floating point value to be truncated and converted to a 64-bit integral integer. |
void HqU32x2FromSize_t | ( | HqU32x2 * | pU32x2, |
size_t | sizet | ||
) |
Fill in a 64-bit unsigned integer from an integral value representing the result of the sizeof()
operator.
[out] | pU32x2 | A pointer to the 64-bit unsigned integer filled in with the pointer difference value. |
[in] | sizet | An integral value, representing the maximum size of an object. |
Return the sign of a 64-bit unsigned integer.
[in] | pU32x2 | A pointer to the 64-bit unsigned integer to be tested. |
0 | Returned if the value stored at pU32x2 is zero. |
1 | Returned if the value stored at pU32x2 is positive. |
Subtract two unsigned 64-bit numbers, storing the difference into a third.
[in] | pU32x2Result | A pointer where the sum of the two inputs is stored. This pointer may be the same as either or both of the inputs. |
[in] | pU32x2A | A pointer to the first operand. |
[in] | pU32x2B | A pointer to the second operand. |
Subtract an unsigned 32-bit integer from an unsigned 64-bit integer, storing the sum into an unsigned 64-bit integer.
[in] | pU32x2Result | A pointer where the difference of the two inputs is stored. This pointer may be the same as the pointer to the first operand. |
[in] | pU32x2A | A pointer to the first operand. |
[in] | ui32 | A 32-bit unsigned integer to be subtracted from the first operand. |
double HqU32x2ToDouble | ( | const HqU32x2 * | pU32x2 | ) |
Convert a 64-bit unsigned integer to a double-precision floating point value. Precision may be silently reduced, depending on the magnitude of the 64-bit integral value.
[in] | pU32x2 | A pointer to the 64-bit unsigned integer to be converted to double. |
Convert a 64-bit unsigned integer to a 32-bit signed integer.
[in] | pU32x2 | The 64-bit unsigned integer to convert. |
[out] | pReturn | A pointer to the converted integer. |
TRUE | Returned if the 64-bit integer's value was in range of the 32-bit integer. |
FALSE | Returned if the 64-bit integer's value was out of range of the 32-bit integer. The value stored in pReturn is not modified in this case. |
Convert a 64-bit unsigned integer to an unsigned value sufficient to represent the size of an object.
[in] | pU32x2 | The 64-bit unsigned integer to convert. |
[out] | sizet | A pointer to the converted integer. |
TRUE | Returned if the 64-bit integer's value was in range of size_t . |
FALSE | Returned if the 64-bit integer's value was out of range of size_t . |
Convert a 64-bit unsigned integer to a 32-bit unsigned integer.
[in] | pU32x2 | The 64-bit unsigned integer to convert. |
[out] | pReturn | A pointer to the converted integer. |
TRUE | Returned if the 64-bit integer's value was in range of the 32-bit integer. |
FALSE | Returned if the 64-bit integer's value was out of range of the 32-bit integer. The value stored in pReturn is not modified in this case. |