I am trying to assign big integer value to a variable in c and when I print I only get 10123456.
What is the issue?
int main(){
long a = 1234567890123456;
printf("\n",sizeof(a));
printf("%ld",a);
}
I am trying to assign big integer value to a variable in c and when I print I only get 10123456.
What is the issue?
int main(){
long a = 1234567890123456;
printf("\n",sizeof(a));
printf("%ld",a);
}
Largest integer type is:
unsigned long long
dont forget about ULL suffix.
or if you need larger integers, take a look for some bigint libraries like gmp.
Of course, there is also long long, but it is also for negative integers and have smaller limits.
Type min max
(signed) long long -9223372036854775808 9223372036854775807
unsigned long long 0 18446744073709551615
long a = 1234567890123456L;
If long is long enough, depends on compiler/OS. If not
long long a = 1234567890123456LL;
If the number is greater than 64-bit, i.e. longer than what unsigned long long can hold, then no data type in C other than string(char[]) will be able to accomodate that value, store it as a string & try writing your own functions to operate (e.g. add, subtract, etc.) on these "very large numbers".