Menu

#4 USA → European DecimalFormat bug

v1.0
open
nobody
None
5
2014-07-04
2013-07-29
No

Hello,

When performing "Evaluation" → "Generate" on a machine with an OS installation that uses the comma (",") as a decimal seperator, the function "roundTwoDecimals" located in '\gnw-3.1b-src\src\ch\epfl\lis\gnw\evaluation\Score.java' erroneously returns results such as "0,01" instead of the proper "0.01".


To fix this I implemented the following workaround (inspired by http://stackoverflow.com/a/5054217/1750173):

double roundTwoDecimals(double d) {
        /*added*/DecimalFormatSymbols otherSymbols = new DecimalFormatSymbols(Locale.US);
        /*changed*/DecimalFormat twoDForm = new DecimalFormat("#.##", otherSymbols);
        return Double.valueOf(twoDForm.format(d));
    }

Good luck implementing this change.

Greetings,

Boris Breuer

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.