Numbers and formatting

Jimmie Houchin jhouchin at cableone.net
Tue Jun 21 19:02:35 UTC 2005


Hello Andreas,

Thanks for the help.

I tried using the truncateTo before but didn't get the results I was 
looking for.

looongNumber truncateTo: 1
looongNumber truncateTo: 2
looongNumber truncateTo: 3

All give strange results when you don't know what your doing. :)

You let me know I could use a decimal number 0.1.
But I wanted two digits after decimal.

looongNumber truncateTo: 0.2
looongNumber truncateTo: 0.3

Also give strange results when you don't know what your doing. :)

But alas I stumbled upon looongNumber truncateTo: 0.01
Yeah! It works. So played some more and learned.

Then I searched the senders, found 5 that actually used it as such.
And a bunch that I have no clue what kind of results they expect.

Thanks Andreas for sharing your wisdom and putting me on the trail 
toward enlightenment. It looks like a looong one. :)

Jimmie


Andreas Raab wrote:
> Try using #truncateTo: or #roundTo: instead of munging around with 
> scaled decimals, e.g.,:
> 
>  ^((byteSize asFloat / (1024*1024)) truncateTo: 0.1) asString, 'mb'
> 
> Cheers,
>   - Andreas
> 
> Jimmie Houchin wrote:
[snip original message]



More information about the Squeak-dev mailing list