Mac OS 9
Math64.h File Reference

64-bit integer math Interfaces. More...

#include <ConditionalMacros.h>
#include <MacTypes.h>

Go to the source code of this file.

Macros

#define S64Div(dividend, divisor)   (S64Divide((dividend), (divisor), NULL))
 
#define U64Div(dividend, divisor)   (U64Divide((dividend), (divisor), NULL))
 
#define SInt64ToWide(x)   (x)
 
#define WideToSInt64(x)   (x)
 
#define UInt64ToUnsignedWide(x)   (x)
 
#define UnsignedWideToUInt64(x)   (x)
 

Functions

SInt64 S64Max (void)
 
SInt64 S64Min (void)
 
SInt64 S64Add (SInt64 left, SInt64 right)
 
SInt64 S64Subtract (SInt64 left, SInt64 right)
 
SInt64 S64Negate (SInt64 value)
 
SInt64 S64Absolute (SInt64 value)
 
SInt64 S64Multiply (SInt64 left, SInt64 right)
 
SInt64 S64Mod (SInt64 dividend, SInt64 divisor)
 
SInt64 S64Divide (SInt64 dividend, SInt64 divisor, SInt64 *remainder)
 
SInt64 S64Set (SInt32 value)
 
SInt64 S64SetU (UInt32 value)
 
SInt32 S32Set (SInt64 value)
 
Boolean S64And (SInt64 left, SInt64 right)
 
Boolean S64Or (SInt64 left, SInt64 right)
 
Boolean S64Eor (SInt64 left, SInt64 right)
 
Boolean S64Not (SInt64 value)
 
SInt32 S64Compare (SInt64 left, SInt64 right)
 
SInt64 S64BitwiseAnd (SInt64 left, SInt64 right)
 
SInt64 S64BitwiseOr (SInt64 left, SInt64 right)
 
SInt64 S64BitwiseEor (SInt64 left, SInt64 right)
 
SInt64 S64BitwiseNot (SInt64 value)
 
SInt64 S64ShiftRight (SInt64 value, UInt32 shift)
 
SInt64 S64ShiftLeft (SInt64 value, UInt32 shift)
 
UInt64 U64Max (void)
 
UInt64 U64Add (UInt64 left, UInt64 right)
 
UInt64 U64Subtract (UInt64 left, UInt64 right)
 
UInt64 U64Multiply (UInt64 left, UInt64 right)
 
UInt64 U64Mod (UInt64 dividend, UInt64 divisor)
 
UInt64 U64Divide (UInt64 dividend, UInt64 divisor, UInt64 *remainder)
 
UInt64 U64Set (SInt32 value)
 
UInt64 U64SetU (UInt32 value)
 
UInt32 U32SetU (UInt64 value)
 
Boolean U64And (UInt64 left, UInt64 right)
 
Boolean U64Or (UInt64 left, UInt64 right)
 
Boolean U64Eor (UInt64 left, UInt64 right)
 
Boolean U64Not (UInt64 value)
 
SInt32 U64Compare (UInt64 left, UInt64 right)
 
UInt64 U64BitwiseAnd (UInt64 left, UInt64 right)
 
UInt64 U64BitwiseOr (UInt64 left, UInt64 right)
 
UInt64 U64BitwiseEor (UInt64 left, UInt64 right)
 
UInt64 U64BitwiseNot (UInt64 value)
 
UInt64 U64ShiftRight (UInt64 value, UInt32 shift)
 
UInt64 U64ShiftLeft (UInt64 value, UInt32 shift)
 
SInt64 UInt64ToSInt64 (UInt64 value)
 
UInt64 SInt64ToUInt64 (SInt64 value)
 

Detailed Description

64-bit integer math Interfaces.

Introduced In: Mac OS 9
Avaliable From: Universal Interfaces 3.4.1
Copyright: © 1994-2001 by Apple Computer, Inc., all rights reserved

For bug reports, consult the following page on the World Wide Web:

http://developer.apple.com/bugreporter/

Macro Definition Documentation

◆ S64Div

#define S64Div (   dividend,
  divisor 
)    (S64Divide((dividend), (divisor), NULL))

can be NULL

◆ SInt64ToWide

#define SInt64ToWide (   x)    (x)

Functions to convert between [Unsigned]Wide and [S|U]Int64 types.

These functions are necessary if source code which uses both wide and SInt64 is to compile under a compiler that supports long long.

SInt64ToWide

        Converts a SInt64 to a wide struct.  If SInt64 is implemented
       as a typedef of wide, the marco does nothing. If SInt64 is
         implememnted as a long long, it casts the long long into a
         wide struct.

WideToSInt64

        Converts a wide struct into a SInt64.  If SInt64 is implemented
         as a typedef of wide, the marco does nothing. If SInt64 is
         implememnted as a long long, it reads the struct into a long

long.

◆ U64Div

#define U64Div (   dividend,
  divisor 
)    (U64Divide((dividend), (divisor), NULL))

can be NULL

Function Documentation

◆ S32Set()

SInt32 S32Set ( SInt64  value)

S32Set()

Discussion: Given an SInt64, returns an SInt32 by discarding the high-order 32 bits.

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ S64Absolute()

SInt64 S64Absolute ( SInt64  value)

S64Absolute()

Discussion: Returns the absolute value of the number (i.e. the number if it is positive, or 0 - the number if it is negative). Disabled for compilers that support long long until llabs() is available everywhere.

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ S64Add()

SInt64 S64Add ( SInt64  left,
SInt64  right 
)

S64Add()

Discussion: Adds two integers, producing an integer result. If an overflow occurs the result is congruent mod (2^64) as if the operands and result were unsigned. No overflow is signaled.

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ S64And()

Boolean S64And ( SInt64  left,
SInt64  right 
)

S64And()

Discussion: Returns one if left and right are non-zero, otherwise returns zero

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ S64BitwiseAnd()

SInt64 S64BitwiseAnd ( SInt64  left,
SInt64  right 
)

S64BitwiseAnd()

Discussion: bitwise AND

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ S64BitwiseEor()

SInt64 S64BitwiseEor ( SInt64  left,
SInt64  right 
)

S64BitwiseEor()

Discussion: bitwise XOR

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ S64BitwiseNot()

SInt64 S64BitwiseNot ( SInt64  value)

S64BitwiseNot()

Discussion: bitwise negate

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ S64BitwiseOr()

SInt64 S64BitwiseOr ( SInt64  left,
SInt64  right 
)

S64BitwiseOr()

Discussion: bitwise OR

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ S64Compare()

SInt32 S64Compare ( SInt64  left,
SInt64  right 
)

S64Compare()

Discussion: Given two signed numbers, left and right, returns an SInt32 that compares with zero the same way left compares with right. If you wanted to perform a comparison on 64-bit integers of the form: operand_1 <operation> operand_2 then you could use an expression of the form: xxxS64Compare(operand_1,operand_2) <operation> 0 to test for the same condition. CAUTION: DO NOT depend on the exact value returned by this routine. Only the sign (i.e. positive, zero, or negative) of the result is guaranteed.

Non-Carbon CFM: not available
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ S64Divide()

SInt64 S64Divide ( SInt64  dividend,
SInt64  divisor,
SInt64 remainder 
)

CALL_NOT_IN_CARBON S64Divide()

Discussion: Divides dividend by divisor, returning the quotient. The remainder is returned in *remainder if remainder (the pointer) is non-NULL. The sign of the remainder is the same as the sign of the dividend (i.e. it takes the absolute values of the operands, does the division, then fixes the sign of the quotient and remainder). If the divisor is zero, then S64Max() will be returned (or S64Min() if the dividend is negative), and the remainder will be the dividend; no error is reported.

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ S64Eor()

Boolean S64Eor ( SInt64  left,
SInt64  right 
)

S64Eor()

Discussion: Returns one if left xor right are non-zero, otherwise returns zero

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ S64Max()

SInt64 S64Max ( void  )

S64Max()

Discussion: Returns largest possible SInt64 value

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ S64Min()

SInt64 S64Min ( void  )

S64Min()

Discussion: Returns smallest possible SInt64 value

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ S64Mod()

SInt64 S64Mod ( SInt64  dividend,
SInt64  divisor 
)

S64Mod()

Discussion: Returns the remainder of divide of dividend by divisor. The sign of the remainder is the same as the sign of the dividend (i.e., it takes the absolute values of the operands, does the division, then fixes the sign of the quotient and remainder).

Non-Carbon CFM: available as macro/inline
Carbon Lib: not available
Mac OS X: not available

◆ S64Multiply()

SInt64 S64Multiply ( SInt64  left,
SInt64  right 
)

!TYPE_LONGLONG S64Multiply()

Discussion: Multiplies two signed numbers, producing a signed result. Overflow is ignored and the low-order part of the product is returned. The sign of the result is not guaranteed to be correct if the magnitude of the product is not representable.

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ S64Negate()

SInt64 S64Negate ( SInt64  value)

S64Negate()

Discussion: Returns the additive inverse of a signed number (i.e. it returns 0 - the number). S64Negate (S64Min) is not representable (in fact, it returns S64Min).

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ S64Not()

Boolean S64Not ( SInt64  value)

S64Not()

Discussion: Returns one if value is non-zero, otherwisze returns zero.

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ S64Or()

Boolean S64Or ( SInt64  left,
SInt64  right 
)

S64Or()

Discussion: Returns one if left or right are non-zero, otherwise returns zero

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ S64Set()

SInt64 S64Set ( SInt32  value)

S64Set()

Discussion: Given an SInt32, returns an SInt64 with the same value. Use this routine instead of coding 64-bit constants (at least when the constant will fit in an SInt32).

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ S64SetU()

SInt64 S64SetU ( UInt32  value)

S64SetU()

Discussion: Given a UInt32, returns a SInt64 with the same value.

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ S64ShiftLeft()

SInt64 S64ShiftLeft ( SInt64  value,
UInt32  shift 
)

S64ShiftLeft()

Discussion: Logical shift of value by the lower 7 bits of the shift.

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ S64ShiftRight()

SInt64 S64ShiftRight ( SInt64  value,
UInt32  shift 
)

S64ShiftRight()

Discussion: Arithmetic shift of value by the lower 7 bits of the shift.

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ S64Subtract()

SInt64 S64Subtract ( SInt64  left,
SInt64  right 
)

S64Subtract()

Discussion: Subtracts two integers, producing an integer result. If an overflow occurs the result is congruent mod (2^64) as if the operands and result were unsigned. No overflow is signaled.

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ SInt64ToUInt64()

UInt64 SInt64ToUInt64 ( SInt64  value)

SInt64ToUInt64()

Discussion: converts SInt64 -> UInt64

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ U32SetU()

UInt32 U32SetU ( UInt64  value)

U32SetU()

Discussion: Given an UInt64, returns an UInt32 by discarding the high-order 32 bits.

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ U64Add()

UInt64 U64Add ( UInt64  left,
UInt64  right 
)

U64Add()

Discussion: Adds two unsigned integers, producing an integer result. If an overflow occurs the result is congruent mod (2^64) as if the operands and result were unsigned. No overflow is signaled.

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ U64And()

Boolean U64And ( UInt64  left,
UInt64  right 
)

U64And()

Discussion: Returns one if left and right are non-zero, otherwise returns zero

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ U64BitwiseAnd()

UInt64 U64BitwiseAnd ( UInt64  left,
UInt64  right 
)

U64BitwiseAnd()

Discussion: bitwise AND

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ U64BitwiseEor()

UInt64 U64BitwiseEor ( UInt64  left,
UInt64  right 
)

U64BitwiseEor()

Discussion: bitwise XOR

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ U64BitwiseNot()

UInt64 U64BitwiseNot ( UInt64  value)

U64BitwiseNot()

Discussion: bitwise negate

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ U64BitwiseOr()

UInt64 U64BitwiseOr ( UInt64  left,
UInt64  right 
)

U64BitwiseOr()

Discussion: bitwise OR

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ U64Compare()

SInt32 U64Compare ( UInt64  left,
UInt64  right 
)

U64Compare()

Discussion: Given two unsigned numbers, left and right, returns an SInt32 that compares with zero the same way left compares with right. If you wanted to perform a comparison on 64-bit integers of the form: operand_1 <operation> operand_2 then you could use an expression of the form: xxxU64Compare(operand_1,operand_2) <operation> 0 to test for the same condition. CAUTION: DO NOT depend on the exact value returned by this routine. Only the sign (i.e. positive, zero, or negative) of the result is guaranteed.

Non-Carbon CFM: not available
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ U64Divide()

UInt64 U64Divide ( UInt64  dividend,
UInt64  divisor,
UInt64 remainder 
)

CALL_NOT_IN_CARBON U64Divide()

Discussion: Divides dividend by divisor, returning the quotient. The remainder is returned in *remainder if remainder (the pointer) is non-NULL. The sign of the remainder is the same as the sign of the dividend (i.e. it takes the absolute values of the operands, does the division, then fixes the sign of the quotient and remainder). If the divisor is zero, then U64Max() will be returned (or U64Min() if the dividend is negative), and the remainder will be the dividend; no error is reported.

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ U64Eor()

Boolean U64Eor ( UInt64  left,
UInt64  right 
)

U64Eor()

Discussion: Returns one if left xor right are non-zero, otherwise returns zero

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ U64Max()

UInt64 U64Max ( void  )

TYPE_LONGLONG || !TYPE_LONGDOUBLE_IS_DOUBLE U64Max()

Discussion: Returns largest possible UInt64 value

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ U64Mod()

UInt64 U64Mod ( UInt64  dividend,
UInt64  divisor 
)

U64Mod()

Discussion: Returns the remainder of divide of dividend by divisor. The sign of the remainder is the same as the sign of the dividend (i.e., it takes the absolute values of the operands, does the division, then fixes the sign of the quotient and remainder).

Non-Carbon CFM: available as macro/inline
Carbon Lib: not available
Mac OS X: not available

◆ U64Multiply()

UInt64 U64Multiply ( UInt64  left,
UInt64  right 
)

U64Multiply()

Discussion: Multiplies two unsigned numbers, producing a signed result. Overflow is ignored and the low-order part of the product is returned. The sign of the result is not guaranteed to be correct if the magnitude of the product is not representable.

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ U64Not()

Boolean U64Not ( UInt64  value)

U64Not()

Discussion: Returns one if value is non-zero, otherwisze returns zero.

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ U64Or()

Boolean U64Or ( UInt64  left,
UInt64  right 
)

U64Or()

Discussion: Returns one if left or right are non-zero, otherwise returns zero

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ U64Set()

UInt64 U64Set ( SInt32  value)

U64Set()

Discussion: Given an SInt32, returns an UInt64 with the same value. Use this routine instead of coding 64-bit constants (at least when the constant will fit in an SInt32).

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ U64SetU()

UInt64 U64SetU ( UInt32  value)

U64SetU()

Discussion: Given a UInt32, returns a UInt64 with the same value.

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ U64ShiftLeft()

UInt64 U64ShiftLeft ( UInt64  value,
UInt32  shift 
)

U64ShiftLeft()

Discussion: Logical shift of value by the lower 7 bits of the shift.

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ U64ShiftRight()

UInt64 U64ShiftRight ( UInt64  value,
UInt32  shift 
)

U64ShiftRight()

Discussion: Arithmetic shift of value by the lower 7 bits of the shift.

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ U64Subtract()

UInt64 U64Subtract ( UInt64  left,
UInt64  right 
)

U64Subtract()

Discussion: Subtracts two unsigned integers, producing an integer result. If an overflow occurs the result is congruent mod (2^64) as if the operands and result were unsigned. No overflow is signaled.

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ UInt64ToSInt64()

SInt64 UInt64ToSInt64 ( UInt64  value)

TYPE_LONGLONG || !TYPE_LONGDOUBLE_IS_DOUBLE UInt64ToSInt64()

Discussion: converts UInt64 -> SInt64

Non-Carbon CFM: available as macro/inline
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later