Re: Bug or feature?
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