Re: rounding a float
Re: rounding a float
- Subject: Re: rounding a float
- From: Steve Bird <email@hidden>
- Date: Sat, 29 Nov 2003 19:32:36 -0500
On Nov 29, 2003, at 7:17 PM, Jay Rimalrick wrote:
>
What is the easiest way to round a float value with either c or
>
objective-c. I
>
need this float value to be consistent with the rounding of currency
>
e.g.
>
1.255 rounds to 1.26 and
>
1.254 rounds to 1.25
Any sort of rounding like this, when you want to affect the number
itself (rather than just the display of the number) is handled by
1... Multiplying the number by 10^n (n = number of dec. places you want
to keep, in your case, 2).
2... Rounding to the nearest integer.
3... Dividing by 10^n (same n, of course).
----------------------------------------------------------------
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
www.Culverson.com (toll free) 1-877-676-8175
_______________________________________________
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.