I do not understand how integral & amp; Decimal value from an NSDecimalnumber.
For example, if I have 10,5, then 10 & amp; nbsp; 5?
And if I have 10 & amp; 5, how back 10,5?
MM is fine, it looks better!
Although I have been involved in decades of losses.
This is for an app that will be international, for example, if the user has set the price "124,2356" then I want to load; Save the exact number
MMM is fine, that's the way, but does not respect # of decimal places. If there is a way to find out if I am present from the local I.
The reason for this is that the currency values represent ...
I'm using was after 2 asked you to scale that was it for the money, but you can choose to use the second rounding scale. . I also rounding can bring this post is a very simple example'm ignoring any exceptions
NSDecimalNumberHandler * Behavior = [NSDecimalNumberHandler decimalNumberHandlerWithRoundingMode: NSRoundDown scale: 0 raiseOnExactness: NO raiseOnOverflow: NO raiseOnUnderflow: NO raiseOnDivideByZero: no]; NSDecimalNumber * value = / * e.g. 10.5 * / / NSDecimalNumber * Dollar = [Price decimal numberBounding AQUIDBETTED: behavior]; NSDecimalNumber * cents = [value decimal numberBybutting: dollar];
This will give you 10 and 0.5 in the dollar
and cents
respectively. If you can use this method to your st
multiplied by the power of 10 to your system if you want the entire number.
cents = [cents decimal number]
Which in return you have multiplied by cents <100>,
in dollars You are giving 10 and 5
and cents
. You should also be aware that you have to split here can use negative powers of 10
So,
st = [St. decimalNumberByMultiplyingByPowerOf10: -2].
will undo that final one.
Comments
Post a Comment