extremely large variables in C++

Programming, for all ages and all languages.
Post Reply
User avatar
AndrewAPrice
Member
Member
Posts: 2303
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

extremely large variables in C++

Post by AndrewAPrice »

How would I define an int128/uint128 and an int256/uint256 in C++?

I'm using GCC and 32-bit x86.
My OS is Perception.
User avatar
os64dev
Member
Member
Posts: 553
Joined: Sat Jan 27, 2007 3:21 pm
Location: Best, Netherlands

Post by os64dev »

256 byte is not possible so you'll have to combine two 128 bits values. I use this but i use long mode so it might not work.

Code: Select all

typedef unsigned __uint128_t __attribute__ (( __mode__ (__TI__)));

typedef struct __uint256_t {
    __uint128_t lo, hi;
} __uint256_t;
Author of COBOS
TomTom
Posts: 23
Joined: Tue May 01, 2007 2:03 am
Location: USA

Post by TomTom »

But gcc doesn't fully support them. Assigning a constant (or generally speaking using them) with more than 64 bits generates compiler errors. It seems impossible to assign a 128 bit value to a 128 bit variable...
User avatar
Kevin McGuire
Member
Member
Posts: 843
Joined: Tue Nov 09, 2004 12:00 am
Location: United States
Contact:

Post by Kevin McGuire »

How would I define an int128/uint128 and an int256/uint256 in C++?
In C++ you would use the power of classes and operator overloading.
Post Reply