Computer Science Canada Problems with Decimal Symbols |
Author: | CooKieLord [ Tue Apr 17, 2007 8:14 am ] | ||
Post subject: | Problems with Decimal Symbols | ||
I am working on a program that converts degrees Celsius to degrees Fahrenheit. I am using doubles for variables, and noticed sometimes I get weird numbers like 45.4444444444444444445. I applied a DecimalFormat in order to reduce the decimals to two values. With all that said, instead of showing 45.44, it would show 45,44. I think the reason for this is that I am working in a French environment. As we all know, in French the decimal symbol is a comma as opposed of a period. The reason why I want to change it is that I made the programs using JTextFields. When I enter a string of sorts, it will not work. Here is the code, as I have said before, I work in a French environment, so don't mind the French comments.
How would I go on about? Is the problem caused by the Locale? If so, how do I change it? If not, is the key in the DecimalFormatSymbol? I tried something but I'm not sure how to use it. Can I also get a small evaluation regarding the legibility of my coding? P.S. On a side note I read something about being able to highlight the syntax. Can someone tell me how? |
Author: | Ultrahex [ Tue Apr 17, 2007 7:15 pm ] |
Post subject: | Re: Problems with Decimal Symbols |
Ya the code works perfect for me (english machine) for syntax highlighting its [syntax="java"] code here [/syntax] (i disabled BBCode so i could show you) |
Author: | CooKieLord [ Sun Apr 29, 2007 3:01 pm ] | ||||||
Post subject: | Re: Problems with Decimal Symbols | ||||||
See, I know that it will work perfectly for English machines. The problem is that I am using a French one at school. I have found a solution to my problem. I used a number format instead of decimal format.
Would become
At which point, I would remove the commented stuff to avoid confusion and fix the output so that i becomes
Anyways, thanks for letting me know about the syntax highlighting and sorry it took so long to reply, my school blocked compsci -_-. |
Author: | Clayton [ Sun Apr 29, 2007 5:14 pm ] |
Post subject: | RE:Problems with Decimal Symbols |
May I ask which school(board) you're from? |
Author: | CooKieLord [ Fri May 04, 2007 6:26 am ] |
Post subject: | RE:Problems with Decimal Symbols |
I'm from CECLFCE Conseil des écoles catholique de langue francaise du centre-est, I think. |