Re: round() returning NaN
Re: round() returning NaN
- Subject: Re: round() returning NaN
- From: Eyal Redler <email@hidden>
- Date: Sun, 03 Apr 2011 01:24:36 +0300
Thanks, Ric, It does look like this is the work of some other code that's wrecking something.
My settings has always had "treat missing prototypes as errors" (and I'm compiling with zero warnings anyway) so I'm not sure we have same case. I'm also not sure I understand your suggestion regarding commenting the function calls.
I also noticed the following facts:
1. The problem doesn't not occur in deployment build, only debug builds
2. I notices that if I put a breakpoint in some particular place of the code the problem doesn't occur: it is as if the actual stopping on the breakpoint cleared the bad stuff that was causing it...
I would appreciate any ideas or directions that you or others might have, this is really worrying and I'm out of ideas...
Eyal
On Apr 1, 2011, at 11:02 PM, Frederick C. Lee wrote:
> 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