ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
On 32 bit architectures, GCC provided 64 bit integer types, with compiled code generally calling some function to do the work, though I do remember seeing this compiled in-line somewhere at one time (maybe a different version or a different compiler or a different architecture ... I have worked with ARM, MIPS, and PPC as well as x86).
Conclusion: it is not that hard to do the steps to implement double sized int arithmetic by a compiler.
So what about doing 128 bit integers on a 64 bit architecture with similar code? That doesn't seem to be implemented in GCC, or if it is, requires some special setting or header to make it (or the types) available. Anyone know how to do this? I'm wanting to avoid using a GMP or similar library for the 128 bit case, and let me just code it like normal arithmetic in C.
Sort of. Looks like gcc 4.4.5 in my Ubuntu 10.10 doesn't have this.
Code:
lorentz/phil /home/phil 70> cat biggerint.c
#include <stdio.h>
int main(int argc, char *argv[])
{
__int128 a = 0;
a += 1590;
printf("sizeof(__int128) = %lu\n", sizeof(a));
return 0;
}
lorentz/phil /home/phil 71> gcc -o biggerint biggerint.c
biggerint.c: In function 'main':
biggerint.c:5: error: '__int128' undeclared (first use in this function)
biggerint.c:5: error: (Each undeclared identifier is reported only once
biggerint.c:5: error: for each function it appears in.)
biggerint.c:5: error: expected ';' before 'a'
biggerint.c:7: error: 'a' undeclared (first use in this function)
lorentz/phil /home/phil 72> find /usr/include -type f -exec fgrep -l __int128 '{}' ';'
lorentz/phil /home/phil 73>
Well, at least I now know WHAT to check for in a future version of gcc if I can get a usable desktop set up on a newer Ubuntu or convert everything I have over to another distro. Any idea just which version of gcc this started working?
I'm not exactly sure when it was "blessed" by the gcc community, but it seems that a preliminary patch was delivered in Jan 2010.
All my reading seems to indicate it is in GCC 4.6+
Thanks for the info. Ubuntu Oneiric (11.10) seems to be where 4.6 begins to be available. Slackware does not have 4.6, yet (maybe whatever follows 13.37 will have it).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.