From 620e3d84e2caee43f4f3f401e9862a760fc3dc20 Mon Sep 17 00:00:00 2001 From: Atsushi Eno Date: Mon, 14 Jun 2004 08:54:31 +0000 Subject: 2004-06-14 Atsushi Enomoto * Double.cs : Use IFormatProvider.GetFormat() instead of literal '-'. * FloatingPointFormatter.cs : Use NumberFormatInfo.NegativeSign. This change saves many XSLT test failures. Format Permille pattern (It is undocumented but actually available, and used in xsl:format-number). svn path=/trunk/mcs/; revision=29483 --- mcs/class/corlib/System/ChangeLog | 9 +++++++++ mcs/class/corlib/System/Double.cs | 8 ++------ mcs/class/corlib/System/FloatingPointFormatter.cs | 12 ++++++++++-- 3 files changed, 21 insertions(+), 8 deletions(-) (limited to 'mcs/class/corlib') diff --git a/mcs/class/corlib/System/ChangeLog b/mcs/class/corlib/System/ChangeLog index 9940358cd51..ebc1a1eb8a9 100644 --- a/mcs/class/corlib/System/ChangeLog +++ b/mcs/class/corlib/System/ChangeLog @@ -1,3 +1,12 @@ +2004-06-14 Atsushi Enomoto + + * Double.cs : Use IFormatProvider.GetFormat() instead of literal '-'. + * FloatingPointFormatter.cs : + Use NumberFormatInfo.NegativeSign. This change saves many XSLT test + failures. + Format Permille pattern (It is undocumented but actually available, + and used in xsl:format-number). + 2004-06-14 Raja R Harinath * Console.cs (Console.Write, Console.WriteLine): Disable __arglist diff --git a/mcs/class/corlib/System/Double.cs b/mcs/class/corlib/System/Double.cs index 756d5979b41..a52c482792a 100644 --- a/mcs/class/corlib/System/Double.cs +++ b/mcs/class/corlib/System/Double.cs @@ -368,12 +368,8 @@ namespace System { public string ToString (string format, IFormatProvider fp) { - if (fp is CultureInfo) - return DoubleFormatter.NumberToString(format, - ((CultureInfo)fp).NumberFormat, m_value); - else - return DoubleFormatter.NumberToString(format, - (NumberFormatInfo)fp, m_value); + NumberFormatInfo nfi = fp != null ? fp.GetFormat (typeof (NumberFormatInfo)) as NumberFormatInfo : null; + return DoubleFormatter.NumberToString (format, nfi, m_value); } // =========== IConvertible Methods =========== // diff --git a/mcs/class/corlib/System/FloatingPointFormatter.cs b/mcs/class/corlib/System/FloatingPointFormatter.cs index a436b03a965..f9d2011bc82 100644 --- a/mcs/class/corlib/System/FloatingPointFormatter.cs +++ b/mcs/class/corlib/System/FloatingPointFormatter.cs @@ -592,7 +592,7 @@ namespace System { return "0"; } if (result.Length > 0) { - result = "-" + result; + result = nfi.NegativeSign + result; } return result; } @@ -628,6 +628,7 @@ namespace System { public int NumberOfColons; public bool Groupping; public bool Percent; + public bool Permille; public int DotPos; public int ExpPos; public int FirstFormatPos; @@ -676,6 +677,9 @@ namespace System { case '%': f.Percent = true; break; + case '\u2030': + f.Permille = true; + break; case 'e': case 'E': f.DecimalLength = count; @@ -705,13 +709,17 @@ namespace System { if (f.FirstFormatPos < 0) { return format; } - if (((f.Percent) || (f.NumberOfColons > 0)) && (f.ExpPos < 0)) { + if (((f.Percent) || (f.Permille) || (f.NumberOfColons > 0)) && (f.ExpPos < 0)) { int len = f.DecimalLength; int exp = 0; if (f.Percent) { len += 2; exp += 2; } + else if (f.Permille) { + len += 3; + exp += 3; + } if (f.NumberOfColons > 0) { len -= (3 * f.NumberOfColons); exp -= 3 * f.NumberOfColons; -- cgit v1.2.3