[Seaside] Smalltalk float to currency how to ?
florian.minjat at emn.fr
Wed Feb 1 10:59:54 CET 2006
I had the same need, so I added this message in Float :
"Answer the float truncated at precision decimal"
(self rounded = self)
ifTrue: [ ^ self rounded ]
ifFalse: [ ^ (((self * (10 raisedTo: precision)) rounded) / (10
raisedTo: precision)) asFloat ]
It's working fine for me.
Dmitry Dorofeev wrote:
> Hi all,
> I have Float in form:
> and want to format it to two-digits-after-dot.
> Searched through classes but found nothing suitable except
> n := 12.6.
> String streamContents: [:s|
> n absPrintOn: s base: 10 digitCount: n asInteger asString size + 2.
> while it works fine for any float like 12.3245
> it does not add zero to float like 12.6 :-(
> I would like to see 12.60
> Is there simple way to do it ?
> like fprintf in C/Perl world ?
> Seaside mailing list
> Seaside at lists.squeakfoundation.org
More information about the Seaside