# Thread: Solution for truncation after 17th Digit?

1. ## Solution for truncation after 17th Digit?

I was trying to write a simple program on C about the classical history between the king, chessboard and rice grains. The total amount of rice grains that is needed to fill the chessboard is : 18 446 744 073 709 551 615 .
But i'm getting : 18 446 744 073 709 552 000. on C.
Aren't there any solution to increase 17 digits resolution? I saw some solutions which were very long and complicated where a newbie like me couldnt understand anything.
Here is my code:

Code:
```#include<stdio.h>
#include<math.h>

int main(void)
{
double i=1.0;
while(i<=64)
{
printf("%2.0lf.Casilla = %.0lf\n", i, pow(2.0,(i-1.0)));
i++;
}
printf("\n\n***En Total = %.0lf Granos.\n\n",pow(2.0,64.0)-1);
return0;
}
``` 2. Originally Posted by Utku Sönmez I was trying to write a simple program on C about the classical history between the king, chessboard and rice grains. The total amount of rice grains that is needed to fill the chessboard is : 18 446 744 073 709 551 615 .
But i'm getting : 18 446 744 073 709 552 000. on C.
Aren't there any solution to increase 17 digits resolution? I saw some solutions which were very long and complicated where a newbie like me couldnt understand anything.
Here is my code:

Code:
```#include<stdio.h>
#include<math.h>

int main(void)
{
double i=1.0;
while(i<=64)
{
printf("%2.0lf.Casilla = %.0lf\n", i, pow(2.0,(i-1.0)));
i++;
}
printf("\n\n***En Total = %.0lf Granos.\n\n",pow(2.0,64.0)-1);
return0;
}
```

Several points:
• The index to a loop is usually an int.
• Why are you calculating the total at the end instead of accumulating in a total variable?
• Are there any floating point data types larger than a double?
• man pow 3. C99 introduced an 'unsigned long long integer' type.

It has a max value (ULLONG_MAX in limits.h) of 18 446 744 073 709 551 615. 4. Originally Posted by gemera C99 introduced an 'unsigned long long integer' type.

It has a max value (ULLONG_MAX in limits.h) of 18 446 744 073 709 551 615.
What data types are returned from the pow() functions?
I was hinting to the OP to do the work, rather than give the answer. 5. Fair dues. I wasn't addressing your post though. Just making the OP aware there is a type available for the problem. If the OP has covered functions a solution is not that difficult. Popular pages Recent additions double, error, help in c, number 