[Newbies] Rouding Floats up to a number of decimals - Method Finder
cdrick65 at gmail.com
Wed Jul 23 12:56:26 UTC 2008
I couldn't find such a function. I tryed in the method finder but find
nothing: MethodFinder methodFor: #(#(1.2288 3) 1.228).
Do somebody know if such a method exist ?
Meanwhile I did that:
Float>>trimAfter: aNumberOfDecimal "roundAfter:"
| number |
number := 10 raisedTo: aNumberOfDecimal.
^(self * 10^aNumber) truncated "rounded" / 10^aNumber asFloat
and still MethodFinder methodFor: #(#(1.2288 3) 1.228) returns '(no
single method does that function) '
whereas 1.2288 roundedAfter: 3 returns 1.229
Does anybody know what was wrong in my method finder use ?
More information about the Beginners