0

How can i store 128 or 256 bit data types(ints and floats) without using any data structures(like arrays and others) and external libraries on a 64-bit machine.I am using codeblocks.

chanzerre
  • 2,409
  • 5
  • 20
  • 28
  • You can't. Not under the conditions you've imposed. – Robert Harvey Sep 05 '13 at 18:12
  • It might depend on your architecture and compiler. For gcc on x64, then you can do 128 bit integers: http://stackoverflow.com/questions/16088282/is-there-a-128-bit-integer-in-gcc – austin Sep 05 '13 at 18:13

1 Answers1

2

You cannot do this using the C language as laid out in the standard. However, depending on your compiler and architecture, you may have compiler-specific support for larger integer sizes. For instance, GCC supplies limited support for 128-bit integers, which you can use like so:

__int128 foo; //foo is a 128-bit signed integer.

However, the real question is probably why you are so determined not to use a library or basic language features like arrays to implement your own.

Michael Rawson
  • 1,905
  • 1
  • 15
  • 25
  • I just wanted to know if I can somehow implement it on my own. – chanzerre Sep 05 '13 at 18:21
  • @chanzerre: you can indeed implement it on your own, but you'll need to use arrays in order to do so. I don't imagine it would be too difficult. :-) – Michael Rawson Sep 05 '13 at 18:22
  • I am trying to implement what you suggested.But gcc doesn't even recognize __int128 and int128_t or uint128_t either.I am using codeblocks on windows platform. – chanzerre Sep 05 '13 at 18:33
  • @chanzerre: Are you sure you're using GCC? If so, you need to be on an architecture which supports it (i.e. 64-bit), and you need to turn off any 'strict C' settings you may have (`-pedantic`, `-ansi`...). It works for me on Linux, x86_64. – Michael Rawson Sep 05 '13 at 18:40