I can’t figure how get the integral & decimal value from a NSDecimalnumber.
For example, if I have 10,5, how get 10 & 5?
And if I have 10 & 5, how return to 10,5?
Mmm ok, that is looking better!
However I have the concer about lossing decimals.
This is for a app that will be international. If for example a user set the price ‘124,2356’ I wanna load & save the exact number.
Mmm ok, that is the way, but not respect the # of decimal places. If exist a way to know that from the current local I’m set.
This is because that represent currency values…
I’m using 2 for the scale since you said this was for currency but you may choose to use another rounding scale. I’m also ignoring any exceptions rounding may bring since this is a pretty simple example.
That will give you 10 and 0.5 in the
dollarsandcentsvariables respectively. If you want whole numbers you can use this method to multiply yourcentsby a power of 10.Which will in turn multiply you
centsby 100, giving you 10 and 5 indollarsandcents. You should also know that you can use negative powers of 10 here to divide.So,
would undo that last method.