Re: rounding a float
Re: rounding a float
- Subject: Re: rounding a float
- From: "Jay Rimalrick" <email@hidden>
- Date: Sun, 30 Nov 2003 12:56:56 -0500
I am attempting write a function that take a float (inFloat) and returns a float
(hopefully rounded for currency)
Here is what I do inside my function:
NSString* myString = [[NSString alloc] init];
myString = [NSString stringWithFormat: @"%f", inFloat];
NSDecimalNumber* myDecimalNumber = [[NSDecimalNumber alloc] init];
myDecimalNumber = [NSDecimalNumber decimalNumberWithString:
myString];
NSDecimalNumber* roundedDecimalNumber = [[NSDecimalNumber alloc]
init];
NSDecimalRound((NSDecimal*)roundedDecimalNumber,
(NSDecimal*)myDecimalNumber, 2, NSRoundPlain);
NSLog(@"%f", [roundedDecimalNumber doubleValue]);
return [roundedDecimalNumber doubleValue]; //i tried float value too
-when I use [roundedDecimalNumber doubleValue] I get the error "myProgram
has exited due to signal 11 (SIGSEGV)" in the debugger it tell me "GDB:
Program received signal: "EXC_BAD_ACCESS""
for some reason it is not passing back the roundedDecimalNumber
any and all help is greatly appreciated
________________________________________________________________
Sent via the WebMail system at 1st.net
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.