[OT]Re: rounding to a multiple of x?
[OT]Re: rounding to a multiple of x?
- Subject: [OT]Re: rounding to a multiple of x?
- From: Graham J Lee <email@hidden>
- Date: Wed, 19 May 2004 18:07:27 +0100
- Organization: Wadham College, Oxford
On 2004-05-19 16:47:23 +0100 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
If we're talking integers, and we call 1149 'x' and 4 'y'...
y*(x/y+1)
If x isn't necessarily an integer...
y*(floor(x/y)+1)
Does something that's either right, or close enough that you can make
it so. I haven't just tested either line though. Well, not in ObjC.
--
Graham Lee
Wadham College
OX1 3PN
_______________________________________________
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.