Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#19 Wrong decimal point for some locales

closed
nobody
None
5
2002-05-06
2002-04-04
Michael Butscher
No

Some text fields present floating point numbers with
"," as decimal point if the decimal format of the
default locale defines it this way (e. g. the german
locale) .

Discussion

  • Peter Eastman
    Peter Eastman
    2002-04-18

    Logged In: YES
    user_id=74743

    Sorry, I'm not entirely certain what you are saying. Do
    you mean that they do that, and they shouldn't? Or that
    they don't do it, and they should?

    I would generally say that localized number formats
    should be used everywhere, but I'm open to comments
    on this.

     
  • Logged In: YES
    user_id=483683

    Sorry, i'm not a native English speaker. I will try to be
    clearer.

    The fields show the values as e. g. "23,4". But they show it
    in red because the value can't be parsed as float due to the
    comma.

    I assume, the program uses the DecimalFormat class to show
    the values (with comma in respect of the locale), but uses
    Double.parseDouble for parsing, which expects a real decimal
    point regardless of the locale.

     
  • Peter Eastman
    Peter Eastman
    2002-04-22

    Logged In: YES
    user_id=74743

    I think I have this fixed, but I don't have any way of
    testing it to make sure. Could you try this out with the
    1.1 beta version (see the Open Discussion list for the
    url to download it from), and confirm whether or not it is
    really fixed?

    Thanks!

    Peter

     
  • Logged In: YES
    user_id=483683

    Floating point entries with comma are now interpreted
    properly, but there is now another problem:

    The locale-respecting fields can't parse the exponential
    representation of a number correctly, e. g. "3,2e4" is
    interpreted as 3.2 (because parsing simply stops before the
    "e") instead of the expected 32000.

    The parse method of DecimalFormat can't handle exponential
    numbers. So i would suggest to let all number fields simply
    ignore the locale (perhaps until someone writes a
    locale-aware number parser which can handle it) because i
    think most people (including me) can live with "." as
    decimal point.

     
  • Peter Eastman
    Peter Eastman
    2002-05-06

    Logged In: YES
    user_id=74743

    Ok. It now uses . as the decimal point regardless of
    locale, and correctly parses exponential notation.

     
  • Peter Eastman
    Peter Eastman
    2002-05-06

    • status: open --> closed