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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to