N
Nobody
I'm trying to understand why this program...
#include <stdio.h>
#include <float.h>
int
main(void)
{
int i = 123456789 ;
int j = 987654321 ;
float k = i ;
float m = j ;
float n ;
float p ;
n = m / 1000000000 ;
p = k + n ;
printf( "%d %d %f %f %f %f %f\n", i, j, k, m, n, k + n, p ) ;
return 0 ;
}
....generates this output:
123456789 987654321 123456792.000000 987654336.000000 0.987654
123456792.987654 123456792.000000
Things confusing me:
1) 123456789 -> 123456792 ("...92" ?)
2) 987654321 -> 987654336 ("...36" ?)
3) Why is storing the result of k + n into p different than the evaluation
of k + n (apparently)?
SuSE Linux 8.2, gcc 3.3 20030226 (prerelease)
It's been years since I've used float. I'm wading through Harbinson &
Steele, but a link to a germane reference (or discussion) would be a big
help, too.
#include <stdio.h>
#include <float.h>
int
main(void)
{
int i = 123456789 ;
int j = 987654321 ;
float k = i ;
float m = j ;
float n ;
float p ;
n = m / 1000000000 ;
p = k + n ;
printf( "%d %d %f %f %f %f %f\n", i, j, k, m, n, k + n, p ) ;
return 0 ;
}
....generates this output:
123456789 987654321 123456792.000000 987654336.000000 0.987654
123456792.987654 123456792.000000
Things confusing me:
1) 123456789 -> 123456792 ("...92" ?)
2) 987654321 -> 987654336 ("...36" ?)
3) Why is storing the result of k + n into p different than the evaluation
of k + n (apparently)?
SuSE Linux 8.2, gcc 3.3 20030226 (prerelease)
It's been years since I've used float. I'm wading through Harbinson &
Steele, but a link to a germane reference (or discussion) would be a big
help, too.