xlong.h File Reference

(r1785/r1261)

Go to the source code of this file.

Classes

class  xlong

Functions

void XlongAdd (const xlong &, const xlong &, xlong &)
 64-bit signed addition
void XlongSub (const xlong &, const xlong &, xlong &)
 64-bit signed subtraction
void XMul64 (const xlong &, const xlong &, xlong &)
 Private to ccmath.h. Primitive for operator overloading.
void XDiv64 (const xlong &, const xlong &, xlong &)
void XlongAsl64 (const xlong &input, INT32 shift, xlong &result)
 Private to ccmath.cpp. Primitive for operator overloading.
void XlongAsr64 (const xlong &input, INT32 shift, xlong &result)
 Private to ccmath.cpp. Primitive for operator overloading.
void XlongAddOne (const xlong &, xlong &)
void XlongSubOne (const xlong &, xlong &)
void XMul64One (const xlong &, xlong &)
void XDiv64One (const xlong &, xlong &)
void XlongNegOne (xlong &)
 64-bit signed negation
void XlongAsl64One (INT32 shift, xlong &result)
void XlongAsr64One (INT32 shift, xlong &result)
void LongToXlong (const INT32, xlong &)
INT32 XlongToLong (const xlong &)
double XlongToDouble (const xlong &)
 Conversion between types. Private to ccmaths.h which has a better interface on top of this.
void DoubleToXlong (const double, xlong &)
 Conversion between types. Private to ccmaths.h which has a better interface on top of this.
INT32 XlongCmpGT (const xlong &first, const xlong &second)
 Private to ccmath.cpp. Primitive for operator overloading.
INT32 XlongCmpGE (const xlong &first, const xlong &second)
INT32 XlongCmpLT (const xlong &first, const xlong &second)
INT32 XlongCmpLE (const xlong &first, const xlong &second)
INT32 XlongCmpEQ (const xlong &first, const xlong &second)
INT32 XlongCmpNE (const xlong &first, const xlong &second)
void XlongIncrement (xlong &)
 Private to ccmath.cpp. Primitive for operator overloading. This is much more efficient than calling Add with a 1 as a second parameter.
void XlongDecrement (xlong &)
 Private to ccmath.cpp. Primitive for operator overloading. This is much more efficient than calling Sub with a 1 as a second parameter.
void XMul32 (INT32, INT32, xlong &)
 To avoid losing precision.
void XlongToAscii (const xlong &, LPSTR)
 Display xlongs in meaningful format.
void XlongToUnicode (const xlong &, WCHAR *)
void XlongByFixed16One (xlong *, fixed16)
 Multiplying without losing precision. Private function used by operator overloading on *=.
INT32 Mul32Div32 (INT32, INT32, INT32)
 To avoid losing precision.
xlong Mul64Div32 (xlong, xlong, INT32)
void XMatrixCalc (fixed16, const xlong &, fixed16, const xlong &, xlong &)
 Matrix multiply primitive done using intermediate 128-bit results so full accuracy is maintained. Special cases are when fix1 or fix2 are 0.0 or 1.0 as multiplications may be avoided (NOT YET IMPLEMENTED) Note that the result is rounded to the nearest integer.

Variables

CCAPI fixed16
 An XLONG is a signed 64-bit value. Its purpose is to represent very large numbers.


Function Documentation

void DoubleToXlong const double  arg,
xlong x
 

Conversion between types. Private to ccmaths.h which has a better interface on top of this.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/6/93
Parameters:
A double for conversion and a reference to an xlong (for the return [INPUTS] value).
Xlong reference is updated with new value [OUTPUTS]
Returns:
None

Errors: None (overflow ignored). No rounding. (I think). Scope: Private

Definition at line 2166 of file xlong.cpp.

02167 {
02168     x = (xlong)arg ;
02169 }

void LongToXlong const   INT32,
xlong
 

INT32 Mul32Div32 INT32  mul1,
INT32  mul2,
INT32  divisor
 

To avoid losing precision.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/4/93 Scope: Private to Xlong class
Parameters:
two multiplicands, one divisor [INPUTS]
result of mul1*mul2/div using 64-bit intermediate result (signed) [OUTPUTS]
Returns:
INT32 result

Errors: If divisor zero or overflow will INT32 0 (div0)

Definition at line 1775 of file xlong.cpp.

01776 {
01777 //  return MulDiv(mul1,mul2,divisor) ;
01778     return INT32(((xlong)mul1*mul2)/divisor) ;
01779 }

xlong Mul64Div32 xlong  ,
xlong  ,
INT32 
 

void XDiv64 const xlong ,
const xlong ,
xlong
 

void XDiv64One const xlong ,
xlong
 

void XlongAdd const xlong input1,
const xlong input2,
xlong result
 

64-bit signed addition

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/4/93 Scope: Private to Xlong class
Parameters:
[INPUTS] 
pointer to the xlong result [OUTPUTS]
Returns:
None

Errors: None (no overflow checks)

Definition at line 1698 of file xlong.cpp.

01699 {
01700     result = input1+input2 ;
01701 }

void XlongAddOne const xlong ,
xlong
 

Definition at line 1703 of file xlong.cpp.

01704 {
01705     result += input ;
01706 }

void XlongAsl64 const xlong input,
INT32  shift,
xlong result
 

Private to ccmath.cpp. Primitive for operator overloading.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/4/93 Scope: Private to Xlong class
Parameters:
64-bit signed xlong, INT32 shift count [INPUTS]
64-bit signed xlong [OUTPUTS]
Returns:
none

Errors: None (overflow ignored). The shift count is masked with 3F for compatibility with normal Intel shifts

Definition at line 1889 of file xlong.cpp.

01890 {
01891     result = input<<shift ;
01892 }

void XlongAsl64One INT32  shift,
xlong result
 

Definition at line 1894 of file xlong.cpp.

01895 {
01896     result <<= shift ;
01897 }

void XlongAsr64 const xlong input,
INT32  shift,
xlong result
 

Private to ccmath.cpp. Primitive for operator overloading.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/4/93 Scope: Private to Xlong class
Parameters:
64-bit signed xlong, INT32 shift count [INPUTS]
64-bit signed xlong [OUTPUTS]
Returns:
none

Errors: None (overflow ignored). The shift count is masked with 3F for compatibility with normal Intel shifts

Definition at line 1917 of file xlong.cpp.

01918 {
01919     result = input>>shift ;
01920 }

void XlongAsr64One INT32  shift,
xlong result
 

Definition at line 1922 of file xlong.cpp.

01923 {
01924     result >>= shift ;
01925 }

void XlongByFixed16One xlong x1,
fixed16  fix
 

Multiplying without losing precision. Private function used by operator overloading on *=.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/5/93
Parameters:
An Xlong (which will be modified) and a FIXED16. [INPUTS]
None [OUTPUTS]
Returns:
Xlong result of x1 * fix

Errors: None (overflow ignored). Scope: Private

Definition at line 2123 of file xlong.cpp.

02124 {
02125     *x1 = xlong( ( (double)*x1 * fix.all ) / ( 1 << 16 ) );
02126 }

INT32 XlongCmpEQ const xlong first,
const xlong second
 

Definition at line 1970 of file xlong.cpp.

01971 {
01972     return first==second ;
01973 }

INT32 XlongCmpGE const xlong first,
const xlong second
 

Definition at line 1955 of file xlong.cpp.

01956 {
01957     return first>=second ;
01958 }

INT32 XlongCmpGT const xlong first,
const xlong second
 

Private to ccmath.cpp. Primitive for operator overloading.

.. = comparison operator, one of: GT > GE >= LT < LE <= EQ == NE !=

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/4/93 Scope: Private to Xlong class
Parameters:
two xlongs [INPUTS]
returns 1 if comparison true, else 0 [OUTPUTS]
Returns:
none

Errors: None

Definition at line 1950 of file xlong.cpp.

01951 {
01952     return first>second ;
01953 }

INT32 XlongCmpLE const xlong first,
const xlong second
 

Definition at line 1965 of file xlong.cpp.

01966 {
01967     return first<=second ;
01968 }

INT32 XlongCmpLT const xlong first,
const xlong second
 

Definition at line 1960 of file xlong.cpp.

01961 {
01962     return first<second ;
01963 }

INT32 XlongCmpNE const xlong first,
const xlong second
 

Definition at line 1975 of file xlong.cpp.

01976 {
01977     return first!=second ;
01978 }

void XlongDecrement xlong input  ) 
 

Private to ccmath.cpp. Primitive for operator overloading. This is much more efficient than calling Sub with a 1 as a second parameter.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/4/93 Scope: Private to Xlong class
Parameters:
64-bit signed xlong [INPUTS]
64-bit signed xlong [OUTPUTS]
Returns:
none

Errors: None (underflow ignored).

Definition at line 2017 of file xlong.cpp.

02018 {
02019     input-- ;
02020 }

void XlongIncrement xlong input  ) 
 

Private to ccmath.cpp. Primitive for operator overloading. This is much more efficient than calling Add with a 1 as a second parameter.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/4/93 Scope: Private to Xlong class
Parameters:
64-bit signed xlong [INPUTS]
64-bit signed xlong [OUTPUTS]
Returns:
none

Errors: None (overflow ignored).

Definition at line 1996 of file xlong.cpp.

01997 {
01998     input++ ;
01999 }

void XlongNegOne xlong arg  ) 
 

64-bit signed negation

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/4/93 Scope: Private to Xlong class
Parameters:
pointer to value requiring negation [INPUTS]
contents of pointer pointer updated [OUTPUTS]
Returns:
None

Errors: None (no overflow checks)

Definition at line 1754 of file xlong.cpp.

01755 {
01756     arg = -arg ;
01757 }

void XlongSub const xlong input1,
const xlong input2,
xlong result
 

64-bit signed subtraction

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/4/93 Scope: Private to Xlong class
Parameters:
[INPUTS] 
pointer to the xlong result (input1 - input2) or (result-=input) [OUTPUTS]
Returns:
None

Errors: None (no overflow checks)

Most of the overhead is in extracting the parameters from the pointers so this does *not* use macros to hide memory models etc

Definition at line 1728 of file xlong.cpp.

01729 {
01730     result = input1-input2 ;
01731 }

void XlongSubOne const xlong ,
xlong
 

Definition at line 1733 of file xlong.cpp.

01734 {
01735     result -= input ;
01736 }

void XlongToAscii const xlong arg,
LPSTR  dest
 

Display xlongs in meaningful format.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/5/93 Scope: Private to Xlong class
Parameters:
64-bit signed xlong [INPUTS]
ASCII string, optional - sign then up to 20 digits, then null byte [OUTPUTS]
Returns:
none

Errors: None

Definition at line 2066 of file xlong.cpp.

02067 {
02068 #if defined(__WXMSW__)
02069     sprintf(dest,"%I64i",arg) ;
02070 #else
02071     sprintf(dest,"%lld",arg) ;
02072 #endif
02073 }

double XlongToDouble const xlong x  ) 
 

Conversion between types. Private to ccmaths.h which has a better interface on top of this.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/6/93
Parameters:
An Xlong [INPUTS]
None [OUTPUTS]
Returns:
A double-precision value

Errors: None (overflow impossible, some precision may be lost) Scope: Private

Definition at line 2144 of file xlong.cpp.

02145 {
02146     return (double)x;
02147 }

INT32 XlongToLong const xlong  ) 
 

void XlongToUnicode const xlong ,
WCHAR
 

Definition at line 2075 of file xlong.cpp.

02076 {
02077 #if defined(__WXMSW__)
02078     swprintf( dest, 21, L"%I64i", arg );
02079 #else
02080     swprintf( dest, 21, L"%lld", arg );
02081 #endif
02082 }

void XMatrixCalc fixed16  fix1,
const xlong l1,
fixed16  fix2,
const xlong l2,
xlong result
 

Matrix multiply primitive done using intermediate 128-bit results so full accuracy is maintained. Special cases are when fix1 or fix2 are 0.0 or 1.0 as multiplications may be avoided (NOT YET IMPLEMENTED) Note that the result is rounded to the nearest integer.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/5/93 Scope: Private to Xlong class
Parameters:
two FIXED16s, two xlongs [INPUTS]
Result returns modified. (32-bit version is a macro). [OUTPUTS]
Returns:
Xlong result of fix1*l1 + fix2*l2

Errors: None (overflow ignored).

Definition at line 2102 of file xlong.cpp.

02103 {
02104     result = xlong(((double)l1*fix1.all+(double)l2*fix2.all)/(1<<16)) ;
02105 }

void XMul32 INT32  mul1,
INT32  mul2,
xlong result
 

To avoid losing precision.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/4/93 Scope: Private to Xlong class
Parameters:
two 32-bit multiplicands [INPUTS]
signed 64-bit [OUTPUTS]
Returns:
none

Errors: None (no overflow checks)

Definition at line 1796 of file xlong.cpp.

01797 {
01798     result = (xlong)mul1*mul2 ;
01799 }

void XMul64 const xlong m1,
const xlong m2,
xlong result
 

Private to ccmath.h. Primitive for operator overloading.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/4/93 Scope: Private to Xlong class
Parameters:
two 64-bit multiplicands [INPUTS]
signed 64-bit (m1*m2 or result*=m) [OUTPUTS]
Returns:
none

Errors: None (no overflow checks)

Definition at line 1819 of file xlong.cpp.

01820 {
01821     result = m1*m2 ;
01822 }

void XMul64One const xlong ,
xlong
 


Variable Documentation

class CCAPI fixed16
 

An XLONG is a signed 64-bit value. Its purpose is to represent very large numbers.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/4/1993
See also:
CCMaths.h

Xlongasm.h

Mul64Div32

Returns:
Errors: None.

Definition at line 120 of file xlong.h.


Generated on Sat Nov 10 03:49:24 2007 for Camelot by  doxygen 1.4.4