# Thread: how to create and save more than 10^18 Integer Data Type?

1. ## how to create and save more than 10^18 Integer Data Type?

hi
i am new to c programming so.
unsigned long long data type have max range up to 18446744073709551615
Code:
`unsigned long long ll = 18446744073709551615;`
how can i create integer data type to save more than 10^18 value ?
thx 2. 3. If you don't need more than 128 bits there are native 128-bit values available on 64-bit machines. The maximum for an unsigned 128-bit value is 340282366920938463463374607431768211455, which is about 3.4 * 10^38.
In gcc and clang the type is called __int128 for signed and unsigned __int128 for unsigned.
Code:
```#include <stdio.h>

const char *to_str(unsigned __int128 n)
{
static char buf;
int i = sizeof buf;
buf[--i] = '\0';
for ( ; n >= 10; n /= 10) buf[--i] = '0' + (int)(n % 10);
buf[--i] = '0' + (int)(n % 10);
return &buf[i];
}

unsigned __int128 from_str(const char *s)
{
unsigned __int128 n = 0;
for ( ; *s; ++s) n = (n * 10) + (*s - '0');
return n;
}

int main()
{
// No 128-bit constants available, so if you want to load it
// with a value larger than 64 bits you need to use a string.
const char *value = "123456789012345678901234567890123456789";

// No predefined I/O routines for __int128, either.
unsigned __int128 n = from_str(value);
n *= 2;
printf("%s\n", to_str(n));

return 0;
}``` Popular pages Recent additions create, data, integer, long, type 