This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: int128 error
- From: Jeffrey Walton <noloader at gmail dot com>
- To: Touros Spoon <touros dot spoon at gmail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Sun, 2 Jan 2011 11:34:10 -0500
- Subject: Re: int128 error
- References: <5044FCFCE8E44925BC8BEBC302649B09@ekws1>
- Reply-to: noloader at gmail dot com
> wibble=170141183460469231731687303715884105727;
wibble=170141183460469231731687303715884105727LL;
or
wibble=170141183460469231731687303715884105727UL;
On Sun, Jan 2, 2011 at 11:24 AM, Touros Spoon <touros.spoon@gmail.com> wrote:
> I have been trying to use the gcc extension __int128, but although I am able
> to declare a variable, when I test it by assigning a value, gcc warns me:
> "constant value is too large for its type".
>
> I am using gcc 4.4.4 on 64 bit Slackware 13.1 with a core 2 duo processor.
>
> This is the code Im using to test it:
>
>
> #include <iostream>
>
> int main ()
>
> {
>
> ? __int128_t wibble;
>
> ? wibble=170141183460469231731687303715884105727;
>
> ? std::cout << "size of wibble: " << sizeof(wibble) << std::endl;
>
> ? return 0;
>
> }
>
>
>
> Unless Im mistaken, the maximum value that a signed int128 should be able to
> cope with is 170141183460469231731687303715884105727. However I tried
> knocking off a few digits to see what happened and the compiler is still
> complaining. The output of the above program displays a sizeof result of 16
> for "wibble" indicating that it is seeing __int128_t as a 16 byte (128 bit)
> integer. So I guess the problem is with the assignment, perhaps something
> Ive missed?
>
> I put this on the gcc list because although it is probably a c++ problem,
> the only resources I can find relevant to this are related to external math
> libraries.
> Has anyone else come accross this problem / can see what I have done wrong
> and if so, please can you advise.
>
> Regards
> TS
>