• 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: round() returning NaN
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: round() returning NaN


  • Subject: Re: round() returning NaN
  • From: "Frederick C. Lee" <email@hidden>
  • Date: Fri, 1 Apr 2011 13:02:30 -0700

I had a similar problem working with iOS.
It turned out that I was corrupting a register or two, so the math function returned NaN.
In my case, I was using the log().

The source of the problem was working with functions that were not properly forward declared.
These functions were originally from an open-source project that I had incorporated into my own iOS project.

The solution was to tighten the compiler warnings
... which includes adding the 'missing function prototypes' & 'treat missing prototypes as  Errors' for the LLVN compiler.

You may have to comment out the math function calls and work back per  per compiler acceptance.

Ric.


On Apr 1, 2011, at 12:43 PM, Eyal Redler wrote:

> Hi,
>
> What possible explanation could be for round() to return NaN when fed with a perfectly nice integral value? My program is consistently doing the following
> 1. I have class method that uses round()
> 2. The method is called once with the value 595 and gives the correct result
> 3. The method is called again with the same value, returning NaN (I can see the bad value in the debugger, immediately after returning from round())
> Also:
> 4. The code belongs in a static library that is included in the main application
> 5. The number I'm feeding round with is actually a float and not a double, changing it to roundf() fixes the issue but I'm worrying this is a sign for some other trouble
> 6. I can see this every time I run the program with the same data
> 7. I wasn't able to reproduce this in another project
> 8. I recently changed many settings in my project - maybe there is some inconsistency between the settings of the main project to the subproject of the static library
> 9. I'm using Xcode 3.2.5
>
> Thanks in advance,
>
> Eyal Redler
> ------------------------------------------------------------------------------------------------
> "If Uri Geller bends spoons with divine powers, then he's doing it the hard way."
> --James Randi
> www.eyalredler.com
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden

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

This email sent to email@hidden

  • Follow-Ups:
    • Re: round() returning NaN
      • From: Eyal Redler <email@hidden>
References: 
 >round() returning NaN (From: Eyal Redler <email@hidden>)

  • Prev by Date: Re: How does XCode propagate build settings to sub projects (or does it at all?)
  • Next by Date: Re: Xcode workflow
  • Previous by thread: round() returning NaN
  • Next by thread: Re: round() returning NaN
  • Index(es):
    • Date
    • Thread