[pypy-svn] r28880 - pypy/dist/pypy/translator/cli/src
antocuni at codespeak.net
antocuni at codespeak.net
Fri Jun 16 14:27:36 CEST 2006
Author: antocuni
Date: Fri Jun 16 14:27:32 2006
New Revision: 28880
Modified:
pypy/dist/pypy/translator/cli/src/pypylib.cs
Log:
This should definitively fix the float formatting issues; there are at
least three ways to convert a float to a string:
- x.ToString(): this has a great precision (8 digits) but it doesn't
write a decimal point when the input is an integer; we really want
the decimal point so that we can distinguish functions that returns
float and functions that returns int.
- x.ToString("F"): this always put the decimal point but it has
2-digit only precision;
- string.Format("{0:F:8}", x): it is a bit involved, but it seems to
be the only way to get both fixed point and 8-digit precision.
Modified: pypy/dist/pypy/translator/cli/src/pypylib.cs
==============================================================================
--- pypy/dist/pypy/translator/cli/src/pypylib.cs (original)
+++ pypy/dist/pypy/translator/cli/src/pypylib.cs Fri Jun 16 14:27:32 2006
@@ -7,8 +7,8 @@
{
public static string ToPython(int x) { return x.ToString(); }
public static string ToPython(bool x) { return x.ToString(); }
- public static string ToPython(double x) { return x.ToString(); }
- public static string ToPython(char x) { return string.Format("'{0}'", x); }
+ public static string ToPython(double x) { return string.Format("{0:F8}", x); }
+ public static string ToPython(char x) { return string.Format("'{0}'", x); }
public static string ToPython(uint x) { return x.ToString(); }
public static string ToPython(long x) { return x.ToString(); }
public static string ToPython(ulong x) { return x.ToString(); }
More information about the Pypy-commit
mailing list