[Pharo-project] Decimal comma

Ricardo Moran richi.moran at gmail.com
Tue Feb 22 23:30:57 CET 2011


I don't know if there is already a way of doing this, but I attached a
simple hack that lets you read commas as decimal points by executing
something like this:

(DecimalCommaNumberParser on: '3,14') nextNumber -> 3.14

I know this is not elegant, but it works. There seems to be some other
places where the decimal point is hardcoded. Maybe we should make
SqNumberParser take the decimal point as a parameter. Or have a preference
to choose that. I don't know...

Cheers
Richo


On Tue, Feb 22, 2011 at 5:53 PM, John Toohey <jt at parspro.com> wrote:

> Without changing the OS locale, is there an easy was to have Pharo
> recognize a comma as a decimal point, i.e. '2,13' asNumber -> 2,13. I
> am receiving number from a Seaside app, in this format, and I need to
> convert them before storing them in Postgres. Currently '2,12'
> asNumber gives 2.
>
> --
> ~JT
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gforge.inria.fr/pipermail/pharo-project/attachments/20110222/e51bebfb/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DecimalCommaNumberParser.st
Type: application/octet-stream
Size: 1380 bytes
Desc: not available
URL: <http://lists.gforge.inria.fr/pipermail/pharo-project/attachments/20110222/e51bebfb/attachment.obj>


More information about the Pharo-project mailing list