• 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: Bug or feature?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug or feature?


  • Subject: Re: Bug or feature?
  • From: Guy English <email@hidden>
  • Date: Tue, 14 Feb 2006 13:46:21 -0500

(oops - sorry about that last empty mail, webmail got a little wacky for a second there)

anyway: the result of a float ( or structure ) return from a nil object is undefined.

Typically, in the case of a float return, you can expect to get whatever value happens to be in the floating point return register. So whatever was sitting at that spot in the register file before floatValue is called will be assigned into fval.

I bet this will work (but is a really, really bad idea relying on undefined behaviour)

- (void) doit
{
    float fval = [[NSNumber numberWithFloat: 0.0] floatValue];
    NSNumber *aNumber=nil;
    fval=[aNumber floatValue];
    NSLog(@"fval is %f",fval);
}

On Tuesday, February 14, 2006, at 01:16PM, Andy Armstrong <email@hidden> wrote:

>On 14 Feb 2006, at 17:57, M. Carlson wrote:
>
>> What number should variable 'fval' have after this is executed?
>>
>> - (void) doit
>> {
>>    float fval=0.0;
>>    NSNumber *aNumber=nil;
>>    fval=[aNumber floatValue];
>>    NSLog(@"fval is %f",fval);
>> }
>
>This describes what it /should/ do:
>  http://lyxus.net/cho
>
>--
>Andy Armstrong, hexten.net
>
> _______________________________________________
>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
>
>
 _______________________________________________
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: 
 >Bug or feature? (From: "M. Carlson" <email@hidden>)
 >Re: Bug or feature? (From: Andy Armstrong <email@hidden>)

  • Prev by Date: Re: floatValue of nil NSNumber unreliable (was Re: Bug or feature?)
  • Next by Date: Re: floatValue of nil NSNumber unreliable (was Re: Bug or feature?)
  • Previous by thread: Re: Bug or feature?
  • Next by thread: Re: Bug or feature?
  • Index(es):
    • Date
    • Thread