• 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: "make positive" function
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "make positive" function


  • Subject: Re: "make positive" function
  • From: Dado Colussi <email@hidden>
  • Date: Mon, 11 Sep 2006 20:43:02 +0200

On Sep 11, 2006, at 20:28, Mike Abdullah wrote:

Basically, I want to take a double and get its closest positive integer. I haven't been able to find anything that does what I want (I have a feeling it might be a modulus?).


Would this do?

long int
closest_positive_integer(double x)
{
	if (x < 1.0) {
		return 1L;	// Smallest positive integer
	} else {
		return lrint(x);
	}
}





_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >"make positive" function (From: Mike Abdullah <email@hidden>)

  • Prev by Date: Re: Unit testing core data
  • Next by Date: NSEditorRegistration - editor argument?
  • Previous by thread: Re: "make positive" function
  • Next by thread: Re: "make positive" function
  • Index(es):
    • Date
    • Thread