#include <stdio.h>
int main()
{
long double n = (long double)1208925819614629174706175; // (1<<80)-1 (generated in python)
printf("%LG\n",n);
}
On compiling this with gcc, I get a warning
test.c:5:31: warning: integer constant is too large for its type [enabled by default]
On running it prints -1
On doing a sizeof(long double)
, it prints 12
.
So a signed long double
should accomodate (1<<83)-1 right?
How do I get it working correctly?
PS: The original problem I was working on, dealt with storing signed integers as large as 12*(1018). I don't want to write multiplication, addition, and other calculation routines. So how do I do it?
Long double will handle 10**300 and above, that's not what the compiler is complaining about. It says the integer that you are trying to cast into a long is too big for an integer. ( hint - add a decimal point ) – starbolin