Re: more float rounding info
Re: more float rounding info
- Subject: Re: more float rounding info
- From: Kyle Moffett <email@hidden>
- Date: Sun, 30 Nov 2003 08:47:25 -0500
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Nov 29, 2003, at 23:32, Jay Rimalrick wrote:
here is my problem upfront and personal:
float aFloat = 0.615;
int aInt = 0;
aFloat = aFloat * 100.0;
aFloat = round(aFloat); //roundf acts the same way as round for me
aInt = (int)aFloat; //just making sure the decimal values are gone
aFloat = aInt / 100.0;
NSLog(@"%f", aInt / 100.0); //this outputs 0.62
NSLog(@"%f", aFloat); //this outputs 0.619999
-this is very weird to me, any and all help is greatly appreciated
Make sure you #include <math.h> somewhere. Otherwise it does
not know what format to use when passing values into and out of
round/roundf/etc
Cheers,
Kyle Moffett
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (Darwin)
iD8DBQE/yfTtag7LSGnFq10RAvE7AKC9JzXcdzc+mxH8Blc5xN0gq9N6ZwCgs4dg
VKGkitJ/0bblwVapfvLLai8=
=a1ry
-----END PGP SIGNATURE-----
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.