- #1
ORF
- 170
- 18
Hello
I am currently using double type for numbers with the format 6f8 (6 digits before the point, 8 digits after the point).
Double structure is enough for this format, or should I use int64_t instead?
Thank you in advance :)
Greetings.
PS: I tried with this example code, but the result it's a bit strange for me... (precision is lost for 4-digit double ? )
http://cpp.sh/8zqfx
The output I got is:
check precision of Double vs uint64_t
3280 3279
3812798742493 3812798742492
I am currently using double type for numbers with the format 6f8 (6 digits before the point, 8 digits after the point).
Double structure is enough for this format, or should I use int64_t instead?
Thank you in advance :)
Greetings.
PS: I tried with this example code, but the result it's a bit strange for me... (precision is lost for 4-digit double ? )
Code:
#include <iostream>
#include "stdint.h"
int main()
{
std::cout << "check precision of Double vs uint64_t\n";
uint64_t k(1);
while( k < 1e14 )
{
k=k*3+1;
//-- check precision of myDouble
double myDouble( k/1e8);
uint64_t test( 1e8 * myDouble );
if( k != test ) std::cout << k << "\t" << test << std::endl;
}
return 0;
}
The output I got is:
check precision of Double vs uint64_t
3280 3279
3812798742493 3812798742492