I want to count the number of decimal places (ignoring trailing zeros) in a Float (or NSDecimalNumber) for example:
1.45000 => 2
5.98 => 2
1.00 => 0
0.8
This is actually really hard due to floating point not being representable precisely in a decimal format. For example the nearest 64 bit IEEE754 floating point to 5.98 is
5.980000000000000426325641456060111522674560546875
Presumably in this case you want the answer to be 2.
The easiest thing to do is to use your favourite converter to a string, formatted to 15 significant figures (for a double precision type) and inspect the output. It's not particularly fast, but it will be reliable. For a 32 bit floating point type, use 7 significant figures.
That said, if you can use a decimal type from the get-go then do that.