• 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: Creating NSDecimal
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating NSDecimal


  • Subject: Re: Creating NSDecimal
  • From: Andrew Farmer <email@hidden>
  • Date: Thu, 30 Oct 2008 23:24:04 -0700

On 30 Oct 08, at 23:18, Graham Cox wrote:
On 31 Oct 2008, at 5:08 pm, HAMILTON, Steven wrote:
Hi folks,
Can someone tell me how I create an NSDecimal? The C struct one, not the ObjC NSDecimalNumber. For performance and simplicity I'd rather use the C interface but for the life of me I can't find out how to actually create one of these and assign a value to it.


//Declare
NSDecimal *decimal;
//assign? Surely its not as simple as this?
decimal = 16.75

It does seem weird that there's no way to create a NSDecimal! I'm pretty sure simple assignment won't work.

It definitely won't. NSDecimal is a structure something like a floating-point value.


The only way I can see is something like this:

NSDecimal decimal = [[NSDecimalNumber decimalNumberWithString:@"16.75"] decimalValue];

maybe that helps?

The other one I was able to find was NSScanner's -scanDecimal: (NSDecimal *) method. It's still really weird that there's no method to initialize one from (say) an integer, though.
_______________________________________________


Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Creating NSDecimal
      • From: Ken Thomases <email@hidden>
References: 
 >Creating NSDecimal (From: "HAMILTON, Steven" <email@hidden>)
 >Re: Creating NSDecimal (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Creating NSDecimal
  • Next by Date: Re: Creating NSDecimal
  • Previous by thread: Re: Creating NSDecimal
  • Next by thread: Re: Creating NSDecimal
  • Index(es):
    • Date
    • Thread