[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 64Bit ints
> I experimented a bit with "long long" variables, and they apparently behave
> just like a nice 64bit int should behave. Arithmetic operations work,
> making arrays of them works, bit shifting/masking works and getting their
> address works. Seems as if we can safely use them...
If you want to stay portable, you probably should make a suite of macros that
take advantage intrinsic 64-bit types/arithmetic if available, and calculate
them manually if not:
typedef unsigned short UInt16;
typedef unsigned long UInt32;
#ifdef INTRINSIC_64BIT /* or something */
typedef unsigned longlong UInt64;
#define Add64(r,x,y) (void) ((r) = (x) + (y))
#else
typedef struct { UInt32 hi, lo; } UInt64;
#define Add64(r,x,y) __MyAdd64(&(r), &(x), &(y))
#endif
Inlining the manual calculations will help their performance a bit.
Matt
/* Matt Slot, Bitwise Operator * One box, two box, yellow box, blue box. *
* <fprefect@ambrosiasw.com> * <http://www.ambrosiasw.com/~fprefect/> */