Default Decimal separator for float parsing and printing

S

sloubi

Hi,
Here is my pb.
I have an application where user can fill float values into <INPUT>

I have to localize my application according to the user definition, not
according to the browser.
So, in France I need the comma, in England it's the dot.

I know the rought solution consisting in 'replacing" dot by comma or
reverse, but:
- it's not clean
- it raises performance considerations, as I manipulate hudge pack of
numbers (matrix or table).

Is there a way to "force" the localization by default?

Regards


Francillo
 
M

Martin Honnen

sloubi said:
Here is my pb.
I have an application where user can fill float values into <INPUT>

Users enter text into an input and your script accesses the value
property of the input element object as a Javascript string so as far as
that goes it is then up to your code to interpret that string as a float.
I have to localize my application according to the user definition, not
according to the browser.
So, in France I need the comma, in England it's the dot.

I know the rought solution consisting in 'replacing" dot by comma or
reverse, but:
- it's not clean
- it raises performance considerations, as I manipulate hudge pack of
numbers (matrix or table).

Is there a way to "force" the localization by default?

If you want to use Javascript functions like parseFloat then it uses '.'
as the decimal separator, there is no way to change that, unless you
write your own function.
 
D

Dr J R Stockton

In comp.lang.javascript message said:
Hi,
Here is my pb.

S'il vous plaît ne pensez pas que les abréviations qui peuvent être
d'usage en français seraient satisfaisante en anglais; on ne devrait
jamais introduire les abréviations lors de l'écriture d'une langue avec
laquelle on ne parle pas couramment.
I have an application where user can fill float values into <INPUT>

I have to localize my application according to the user definition, not
according to the browser.
So, in France I need the comma, in England it's the dot.

I know the rought solution consisting in 'replacing" dot by comma or
reverse, but:
- it's not clean
- it raises performance considerations, as I manipulate hudge pack of
numbers (matrix or table).


Have you determined whether the necessary substitution will have a
perceptible influence on performance? Firefox 3, 3GHz P4, can convert
"12345,67" to "12345.67" in under 5 us. Very few users can type a
number accurately in less than 200 ms.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top