NLPACS::CInt128 Class Reference

#include <edge_collide.h>


Detailed Description

A 128 bits integer.
Author:
Lionel Berenguier

Nevrax France

Date:
2001

Definition at line 48 of file edge_collide.h.

Public Member Functions

bool operator< (const CInt128 &o) const
 compare 2 int128.

bool operator== (const CInt128 &o) const
 compare 2 int128.

void setMul (sint64 a, sint64 b)
 Compute a*b, and store in CInt128.


Data Fields

sint64 High
sint64 Low


Member Function Documentation

bool NLPACS::CInt128::operator< const CInt128 o  )  const [inline]
 

compare 2 int128.

Definition at line 99 of file edge_collide.h.

References High, and Low.

00100         {
00101                 if(High!=o.High)
00102                         return High<o.High;
00103                 else
00104                         return Low<o.Low;
00105         }

bool NLPACS::CInt128::operator== const CInt128 o  )  const [inline]
 

compare 2 int128.

Definition at line 108 of file edge_collide.h.

References High, and Low.

00109         {
00110                 return High==o.High && Low==o.Low;
00111         }

void NLPACS::CInt128::setMul sint64  a,
sint64  b
[inline]
 

Compute a*b, and store in CInt128.

Definition at line 57 of file edge_collide.h.

References High, Low, sint, sint64, uint32, and uint64.

Referenced by NLPACS::CRational64::operator<(), and NLPACS::CRational64::operator==().

00058         {
00059                 // reset and backup sign.
00060                 sint    sgn=0;
00061                 if(a<0)
00062                         sgn++, a=-a;
00063                 if(b<0)
00064                         sgn--, b=-b;
00065 
00066 
00067                 // compute unsigned version.
00068                 uint64  high, low, hl1, hl2, oldLow;
00069                 uint32  mask32= 0xFFFFFFFF;
00070                 high= (a>>32) * (b>>32);
00071                 low=  (a&mask32) * (b&mask32);
00072                 hl1=  (a&mask32) * (b>>32);
00073                 hl2=  (a>>32) * (b&mask32);
00074                 // add/adc hl1.
00075                 oldLow= low;
00076                 low+= (hl1&mask32) << 32;
00077                 if(low<oldLow)
00078                         high++;
00079                 high+= (hl1>>32);
00080                 // add/adc hl2.
00081                 oldLow= low;
00082                 low+= (hl2&mask32) << 32;
00083                 if(low<oldLow)
00084                         high++;
00085                 high+= (hl2>>32);
00086 
00087 
00088                 // extend with sign.
00089                 High= high;
00090                 Low= low;
00091                 if(sgn!=0)
00092                 {
00093                         High= -High;
00094                         Low= -Low;
00095                 }
00096         }


Field Documentation

sint64 NLPACS::CInt128::High
 

Definition at line 51 of file edge_collide.h.

Referenced by operator<(), operator==(), and setMul().

sint64 NLPACS::CInt128::Low
 

Definition at line 52 of file edge_collide.h.

Referenced by operator<(), operator==(), and setMul().


The documentation for this class was generated from the following file:
Generated on Tue Mar 16 14:14:43 2004 for NeL by doxygen 1.3.6