Skip to content

Commit 1b616ef

Browse files
committedJun 19, 2017
Bug fix: must use InvariantCulture when writing numbers into expressions.
1 parent bfbc744 commit 1b616ef

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed
 

‎CalcForm.cs

+6-5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.Data;
99
using System.Diagnostics;
1010
using System.Drawing;
11+
using System.Globalization;
1112
using System.Linq;
1213
using System.Windows.Forms;
1314

@@ -63,9 +64,8 @@ private void CalcForm_Load(object sender, EventArgs e)
6364
+ "(x**2+y**2-1)**3 == x**2*y**3 // Heart\n"
6465
+ "@purple rnd()*abs(x*y)<0.25 // Noisy star\n"
6566
+ "x^2+y^2 < 4 || (+y < 0.5 && +x < 4) || (+y < 5 && +x in (4,5)) // Tie fighter\n"
66-
+ "4 % x\n"
67-
+ "\n");
68-
SetUpComboBox(cbVariables, "Variables", $"x=1\n"
67+
+ "4 % x\n" + "\n");
68+
SetUpComboBox(cbVariables, "Variables", "x=1\n"
6969
+ "x=1; r=sqrt(x**2+y**2); theta=mod(atan(y,x),tau)");
7070
SetUpComboBox(cbRanges, "Ranges", "-10..10;\n"
7171
+"-5..5; \n"
@@ -159,7 +159,8 @@ OutputState PrepareCalculators()
159159
try {
160160
// Parse the three combo boxes and build a dictionary of variables
161161
var exprs = ParseExprs("Formula", cbFormulas.Text);
162-
var variables = ParseExprs("Variables", $"pi={Math.PI};tau={Math.PI*2};e={Math.E};phi=1.6180339887498948; {cbVariables.Text}");
162+
var variables = ParseExprs("Variables", string.Format(CultureInfo.InvariantCulture,
163+
"pi={0};tau={1};e={2};phi=1.6180339887498948; {3}", Math.PI, Math.PI*2, Math.E, cbVariables.Text));
163164
var ranges = ParseExprs("Range", cbRanges.Text);
164165
var varDict = CalculatorCore.ParseVarList(variables);
165166

@@ -313,7 +314,7 @@ private void btnCopy_Click(object sender, EventArgs e)
313314
void SetRanges(CalcRange xRange, CalcRange yRange, string zRangeText)
314315
{
315316
// Refreshes display as side effect
316-
var newRanges = string.Format("{0:G8}..{1:G8}; {2:G8}..{3:G8}; {4}",
317+
var newRanges = string.Format(CultureInfo.InvariantCulture, "{0:G8}..{1:G8}; {2:G8}..{3:G8}; {4}",
317318
xRange.Lo, xRange.Hi, yRange.Lo, yRange.Hi, zRangeText);
318319
Trace.WriteLine(newRanges);
319320
cbRanges.Text = newRanges;

0 commit comments

Comments
 (0)