If all you have to do is read from the slider, save the values and represent them, dealing with primitive integers derived from a scaled, rounded float input of the slider, I would recommend. In any case, the slider does not exactly enter the input method, so your users will not notice if rounding the position of the slider is rounded.
I would use the same reasoning as when determining the number of significant digits from a calculation that takes real-world data as its input (for example, reading the temperature, etc.). It makes no sense to report a calculation of up to four significant digits if your original source has only two digits.
NSDecimals and NSDecimalNumbers are necessary if you want to do more advanced decimal calculations, but want to avoid floating point errors. For example, I use them when performing high-precision calculations in my application or if I need to somehow manipulate the currency. Of the two, I stick with NSDecimal for performance reasons , using NSDecimalNumber in cases where I need to interact with Core Data or need to import numeric values into NSDecimal structs.
In this case, it seems that NSDecimal will be redundant, because you are in no way adjusting the values of the slider just by displaying them on the screen. If you needed to perform the following manipulations (cutting in half, executing a formula, etc.), I would recommend rounding the slider to an integer representation by creating an NSDecimal structure, doing the calculations as NSDecimals, and then using the string output procedures for NSDecimal / NSDecimalNumber to display result on screen. Then you can easily save the calculated value as NSDecimalNumber in Core Data or as a string representation in SQLite or another file.
In addition, I would not worry too much about performance in simple computing, for example, until something like “Tools” tells you that this is a hot spot. Most likely, these calculations are with NSDecimal, etc. Will not.
source share