Re: rounding to a multiple of x?
Re: rounding to a multiple of x?
- Subject: Re: rounding to a multiple of x?
- From: Clark Cox <email@hidden>
- Date: Wed, 19 May 2004 13:16:16 -0400
On May 19, 2004, at 11:47, email@hidden wrote:
Greetings,
I can't seem to figure out how to roundup to a multiple of a number ie
if i have 1149 and i want to round up to a multiple of 4 how would
accomplish this? any direction would be great
Essentially, you just need to divide by 4, round up to the nearest
integer, and multiply by four again. Something like:
x = 1149;
For floating point:
x = 4 * ceil(x / 4);
For integer:
x = 4 * ((x+3) / 4);
--
Clark S. Cox III
email@hidden
http://homepage.mac.com/clarkcox3/
http://homepage.mac.com/clarkcox3/blog/B1196589870/index.html
_______________________________________________
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.