• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: rounding to a multiple of x?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


References: 
 >rounding to a multiple of x? (From: email@hidden)

  • Prev by Date: [newbie] looking for help for my 1st decent project
  • Next by Date: Lifetime of an NSURLHandle
  • Previous by thread: Re: rounding to a multiple of x?
  • Next by thread: Re: rounding to a multiple of x?
  • Index(es):
    • Date
    • Thread