• 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: Peter Borg <email@hidden>
  • Date: Wed, 19 May 2004 19:28:16 +0200

This should work if you want to round it upwards:

unsigned int value = 1149;
unsigned int missing = value % 4;
if (missing) value = 4 - missing + value;

value should now be 1152.

Regards,

Peter

On 19 maj 2004, at 17.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
_______________________________________________
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.
_______________________________________________
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: [OT]Re: rounding to a multiple of x?
  • Next by Date: [newbie] looking for help for my 1st decent project
  • Previous by thread: Re: [OT]Re: rounding to a multiple of x?
  • Next by thread: Re: rounding to a multiple of x?
  • Index(es):
    • Date
    • Thread