discuss-gnustep
[Top][All Lists]
Advanced

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

Re: NSNumber and long double


From: Daniel J Farrell
Subject: Re: NSNumber and long double
Date: Sun, 6 May 2007 12:57:53 +0100

Hi,

Sounds like that is a bug in the documentation then, thanks for clearing that up. How do I report this bug?

Cheers,

Daniel






On 6 May 2007, at 10:02, David Ayers wrote:

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]