[Mono-list] number formatting
Martin Weindel
martin.weindel@t-online.de
Sat, 13 Oct 2001 22:40:13 +0200
This is a multi-part message in MIME format.
------=_NextPart_000_0144_01C15438.05849000
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Derek,
I'm already working hard on the decimal type and will be finished in a =
few days.
- Martin
----- Original Message -----=20
From: Derek Holden=20
To: mono-list@ximian.com=20
Sent: Wednesday, October 10, 2001 2:56 PM
Subject: [Mono-list] number formatting
I just added the number formatting for the integer types if anyone =
wants to
play with it. I have a test that does
string[] formats =3D {
"C", "C0", "C1", ... "C99",
"D", "D0", "D1", ... "D99",
"E", "E0", "E1", ... "E99",
"F", "F0", "F1", ... "F99",
"G", "G0", "G1", ... "G99",
"N", "N0", "N1", ... "N99",
"P", "P0", "P1", ... "P99",
"X", "X0", "X1", ... "X99"
};
for (int n =3D -10000; n < 10000; n++)
foreach (string format in formats)
if ( [microsoft's] n.ToString(format) !=3D [mono's] =
n.ToString(format) )
say something;
For all ints, uints, shorts, ushorts, longs, ulongs, sbytes, and =
bytes. It
seems to be passing all the tests. If there is anyone who is =
interested in
making an NUnit test for all that I'll send my test to them. I haven't
played w/ NUnit enough to know if there would be an easier way other =
than a
million lines of Assert(n.ToString("C4"), "$42,321.0000")'s.
It also seems to be using the NumberFormatInfo stuff properly, but =
that'd be
even harder to write a test for. There's a lot you can do with the
NumberFormatInfo patterns and symbols to get custom printings of =
currency
and percents and stuff, but you have to set up a FormatProvider and =
lay out
patterns. If anyone is interested in NUnit'ing that I can send some =
tests I
did with it.
I was planning on working on the decimal types next.
_______________________________________________
Mono-list maillist - Mono-list@ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list
------=_NextPart_000_0144_01C15438.05849000
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4522.1800" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Derek,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I'm already working hard on the decimal =
type and=20
will be finished in a few days.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>- Martin</FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV=20
style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>From:</B>=20
<A title=3Ddsh2120@draper.com href=3D"mailto:dsh2120@draper.com">Derek =
Holden</A>=20
</DIV>
<DIV style=3D"FONT: 10pt arial"><B>To:</B> <A =
title=3Dmono-list@ximian.com=20
href=3D"mailto:mono-list@ximian.com">mono-list@ximian.com</A> </DIV>
<DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Wednesday, October 10, =
2001 2:56=20
PM</DIV>
<DIV style=3D"FONT: 10pt arial"><B>Subject:</B> [Mono-list] number=20
formatting</DIV>
<DIV><BR></DIV>I just added the number formatting for the integer =
types if=20
anyone wants to<BR>play with it. I have a test that does<BR><BR> =
string[] formats =3D {<BR> "C", "C0", "C1", ...=20
"C99",<BR> "D", "D0", "D1", ... =
"D99",<BR> =20
"E", "E0", "E1", ... "E99",<BR> "F", "F0", "F1", ... =
"F99",<BR> "G", "G0", "G1", ... =
"G99",<BR> =20
"N", "N0", "N1", ... "N99",<BR> "P", "P0", "P1", ... =
"P99",<BR> "X", "X0", "X1", ... =
"X99"<BR> =20
};<BR><BR> for (int n =3D -10000; n < 10000;=20
n++)<BR> foreach (string format in=20
formats)<BR> if ( [microsoft's]=20
n.ToString(format) !=3D [mono's] n.ToString(format) )<BR>say=20
something;<BR><BR>For all ints, uints, shorts, ushorts, longs, ulongs, =
sbytes,=20
and bytes. It<BR>seems to be passing all the tests. If there is anyone =
who is=20
interested in<BR>making an NUnit test for all that I'll send my test =
to them.=20
I haven't<BR>played w/ NUnit enough to know if there would be an =
easier way=20
other than a<BR>million lines of Assert(n.ToString("C4"),=20
"$42,321.0000")'s.<BR><BR>It also seems to be using the =
NumberFormatInfo stuff=20
properly, but that'd be<BR>even harder to write a test for. There's a =
lot you=20
can do with the<BR>NumberFormatInfo patterns and symbols to get custom =
printings of currency<BR>and percents and stuff, but you have to set =
up a=20
FormatProvider and lay out<BR>patterns. If anyone is interested in =
NUnit'ing=20
that I can send some tests I<BR>did with it.<BR><BR>I was planning on =
working=20
on the decimal types=20
=
next.<BR><BR><BR>_______________________________________________<BR>Mono-=
list=20
maillist - <A=20
href=3D"mailto:Mono-list@ximian.com">Mono-list@ximian.com</A><BR><A=20
=
href=3D"http://lists.ximian.com/mailman/listinfo/mono-list">http://lists.=
ximian.com/mailman/listinfo/mono-list</A></BLOCKQUOTE></BODY></HTML>
------=_NextPart_000_0144_01C15438.05849000--