discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSNumber and long double


From: David Ayers
Subject: Re: NSNumber and long double
Date: Sun, 06 May 2007 11:02:00 +0200
User-agent: Mozilla Thunderbird 1.0.2 (X11/20070113)

Hello Daniel,

Daniel J Farrell schrieb:

> Can NSNumber containing long double data-type?

Not that I know of.

> The docs say in order  to
> return a number as a long double, use:
> 
> - (long)longValue Returns the receiver's value as a long double 
> precision floating point value.

long is a discrete integer type, long double is a floating point type.
Which documentation are you referring to here as it seems to me to be a
bug in the documentation.  It should read something like:

- (long)longValue Returns the receiver's value as a signed long value.

> In the example below I am using +numberWithLong:, however when  returned
> this prints out a NaN.
> 
>   long double num = 1e300;
>   NSNumber *d = [NSNumber numberWithLong:num];
>   printf("\n\n%Le",[d longValue]);
> 
>   //output nan
> 
> How do I use long doubles with GNUstep?

My first suggestion would be a custom subclass of NSNumber.  In the long
run I believe that Apple may extend the Cocoa API to support long double
in the future.  (Especially if people request it there.)

I'm not sure how wise it would be to extend GNUstep's API now and
thereby risk people writing non-portable code.  But I certainly wouldn't
object either.  Maybe one could use the versioning-macro-machinery to
hide the extension if requested, but I must admit that that machinery
still scares me.

Cheers,
David




reply via email to

[Prev in Thread] Current Thread [Next in Thread]