Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Numbers with commas

by l3nz (Friar)
on May 13, 2004 at 07:32 UTC ( #353003=note: print w/replies, xml ) Need Help??


in reply to Numbers with commas

As far as I know, Perl only allows underscores as number beautyfiers, like 1_000_230 instead of 1,000,230, but I guess they get thrown out by the parser as soon as they're found.

The point with parsing a (maybe user input) string is that there is no correct way to handle commas and dots if yuou don't take you LOCALE into consideration. The string 2,500 written by an american is two thousand five hundred, by an italian is two and a half. And such numbers can be rather ambiguous, both in reading and in input. The standard computer notation uses only the dot for the decimal part and no commas and it's in most cases unambiguous. In all other cases you'll have to rely on the locale, and you should not expect a language to do it by itself (Java does if you don't tell it; but then, how do you know which version of the system was installed on the Linux box of your Hungarian branch?)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://353003]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (1)
As of 2022-08-07 18:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?