|
-
March 1st, 2000, 04:52 PM
#1
decimal
Hi )
I've a value : 3.5463729
But I want to keep only the value : 3.55
Is there a function to round decimals
Thanks !
Duke :-)
-
March 2nd, 2000, 04:51 AM
#2
Re: decimal
try this
float f = 3.5463729;
f *= 100.0f;
int i = (int)f;//truncate
f = ((float)i) / 100.0f;
//or combine to save typing
f = ((float)((int)(f * 100))) /100.0f;
not tested but it should work. The idea is to move the decimal right 2, truncate, the move the decimal back
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|