![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Now, you can assemble part of a string with the correct characteristics by
first converting the truncated Float
instance to a string:
self truncated printString , '.'
Then, to add the postdecimal-point digits, you repeatedly multiply the fractional part by 10 to push the required fractional digits to the left of the decimal point:
fraction := (self - self truncated) abs. f timesRepeat: [fraction := 10 * fraction. ^ ./]. | *-- argument of andFraction:
Then, truncating the result, taking the absolute value, and converting to a string produces a digit ready for concatenation:
fraction := (self - self truncated) abs. f timesRepeat: [fraction := 10 * fraction. string := string , fraction truncated printString. ./].