Menu

#70 Add custom decimal separator to calculator

open
nobody
5
2003-01-30
2003-01-30
No

Add a method for a user to specify the decimal
separator charactor used in the calculator. Here is how I
propose that the change should be made:

in <localprefs.js>:
/* Calculator decimal separator character.
* Value can be almost any character not used for
computation.
* Default value is '.' (period), if no value is set
*/
calculatorDecimal = ",";

in <calculate.js>:
9 if (typeof calculatorDecimal != "undefined" &&
calculatorDecimal != "") {
10 var re = new RegExp("\\" +
calculatorDecimal, "g");
11 expr = expr.replace(re, ".");
12 }
13 with(Math)

24 if (typeof calculatorDecimal != "undefined"
&& calculatorDecimal != "")
25 answer = answer.toString().replace(/\./g,
calculatorDecimal);
26 setSearchWindowText(answer, true);

Discussion