Skip to content

Commit 381fe65

Browse files
committed
Use culture independent ToString for converting doubles to string
1 parent 94a0c59 commit 381fe65

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

GnuPlot.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.IO;
55
using System.Threading;
66
using System.Linq;
7+
using System.Globalization;
78

89
namespace AwokeKnowing.GnuplotCSharp
910
{
@@ -374,15 +375,15 @@ public static void SPlot(List<StoredPlot> storedPlots)
374375
public static void WriteData(double[] y, StreamWriter stream, bool flush = true)
375376
{
376377
for (int i = 0; i < y.Length; i++)
377-
stream.WriteLine(y[i].ToString());
378+
stream.WriteLine(y[i].ToString(CultureInfo.InvariantCulture));
378379

379380
if (flush) stream.Flush();
380381
}
381382

382383
public static void WriteData(double[] x, double[] y, StreamWriter stream, bool flush = true)
383384
{
384385
for (int i = 0; i < y.Length; i++)
385-
stream.WriteLine(x[i].ToString() + " " + y[i].ToString());
386+
stream.WriteLine(x[i].ToString(CultureInfo.InvariantCulture) + " " + y[i].ToString(CultureInfo.InvariantCulture));
386387

387388
if (flush) stream.Flush();
388389
}
@@ -393,7 +394,7 @@ public static void WriteData(int ySize, double[] z, StreamWriter stream, bool fl
393394
{
394395
if (i > 0 && i % ySize == 0)
395396
stream.WriteLine();
396-
stream.WriteLine(z[i].ToString());
397+
stream.WriteLine(z[i].ToString(CultureInfo.InvariantCulture));
397398
}
398399

399400
if (flush) stream.Flush();
@@ -408,7 +409,7 @@ public static void WriteData(double[,] zz, StreamWriter stream, bool flush = tru
408409
{
409410
line = "";
410411
for (int j = 0; j < n; j++)
411-
line += zz[i, j].ToString() + " ";
412+
line += zz[i, j].ToString(CultureInfo.InvariantCulture) + " ";
412413
stream.WriteLine(line.TrimEnd());
413414
}
414415

@@ -423,7 +424,8 @@ public static void WriteData(double[] x, double[] y, double[] z, StreamWriter st
423424
{
424425
if (i > 0 && x[i] != x[i - 1])
425426
stream.WriteLine("");
426-
stream.WriteLine(x[i] + " " + y[i] + " " + z[i]);
427+
428+
stream.WriteLine(string.Format(CultureInfo.InvariantCulture, "{0} {1} {2}", x[i], y[i], z[i]));
427429
}
428430

429431
if (flush) stream.Flush();

0 commit comments

Comments
 (0)