Re: Creating NSDecimal
Re: Creating NSDecimal
- Subject: Re: Creating NSDecimal
- From: Roland King <email@hidden>
- Date: Fri, 31 Oct 2008 14:21:30 +0800
looking at the documentation I think you need to start with an
NSDecimalNumber then use one of the member functions to convert it to an
NSDecimal, do the things you want to do on it, and convert it back again.
Remember also that NSDecimal is really just a structure, not an object,
so when you declare it you'd normally do it on the stack, not as a pointer.
so I think I'd try something like
NSDecimal decinum = [ [ NSDecimalNumber decimalNumberWithMantissa:1675
exponent:-2 isNegative:NO ] decimalValue ];
I suppose you could try to make one directly by doing
NSDecimal myDec;
then setting myDec._exponent and myDec._mantissa[], if you can figure
out how it stores its mantissa but that seems to be more work and they
are private so you'd be opening yourself up to apple changing the whole
thing later.
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<file:///\\assign>? Surely its not as simple as this?
decimal = 16.75
Steven Hamilton | Solutions Designer | BT Infrastructure | Business Technology | Suncorp | Tel: 07 3135 4684
email@hidden | Level 27, Brisbane Square, 266 George Street, Brisbane
________________________________
This e-mail is sent by Suncorp-Metway Limited ABN 66 010 831 722 or one of its related entities "Suncorp".
Suncorp may be contacted at Level 18, 36 Wickham Terrace, Brisbane or on 13 11 55 or at suncorp.com.au.
The content of this e-mail is the view of the sender or stated author and does not necessarily reflect the view of Suncorp. The content, including attachments, is a confidential communication between Suncorp and the intended recipient. If you are not the intended recipient, any use, interference with, disclosure or copying of this e-mail, including attachments, is unauthorised and expressly prohibited. If you have received this e-mail in error please contact the sender immediately and delete the e-mail and any attachments from your system.
If this e-mail constitutes a commercial message of a type that you no longer wish to receive please reply to this e-mail by typing Unsubscribe in the subject line.
_______________________________________________
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
_______________________________________________
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