#include <stdio.h>
// double has 2x the precision of float.
// double has 15 decimal digits of precision, while float has 7.
void float_check() {
float a = 0.01234f;
float b = 0;
for (int i = 0; i < 813; i++) {
b += a;
}
printf("%.7g\n", b);
}
void double_check() {
double a = 0.01234;
double b = 0;
for (int i = 0; i < 813; i++) {
b += a;
}
printf("%.15g\n", b);
}
int main() {
float_check();
double_check();
return 0;
}
// calculator = 10.03242
/*
run:
10.03238
10.03242
*/