[Mono-list] Maths

Jochen Wezel jwezel@compumaster.de
Mon, 9 Feb 2004 19:14:20 +0100


This is a multi-part message in MIME format.

------_=_NextPart_001_01C3EF38.89F4778C
Content-Type: text/plain;
	charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable

Hi!

Has anybody seen that behaviour yet which is produced by MS .Net?

When rounding doubles to integer, there is a rounding error:
        Console.WriteLine(Convert.ToInt32(1.5)) 'is 2  - should be 2
        Console.WriteLine(Convert.ToInt32(2.5)) 'is 2  - should be 3

This may be important for those guys who are programming in that area...

Jochen

------_=_NextPart_001_01C3EF38.89F4778C
Content-Type: text/html;
	charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dus-ascii">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
6.5.6944.0">
<TITLE>Maths</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->

<P><FONT SIZE=3D2 FACE=3D"Arial">Hi!</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">Has anybody seen that behaviour yet =
which is produced by MS .Net?</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">When rounding doubles to integer, there =
is a rounding error:<BR>
</FONT><FONT SIZE=3D2 FACE=3D"Courier =
New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
Console.WriteLine(Convert.ToInt32(1.5)) </FONT><FONT COLOR=3D"#008000" =
SIZE=3D2 FACE=3D"Courier New">'is 2&nbsp; - should be 2</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Courier =
New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
Console.WriteLine(Convert.ToInt32(2.5)) </FONT><FONT COLOR=3D"#008000" =
SIZE=3D2 FACE=3D"Courier New">'is 2&nbsp; - should be 3</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">This may be important for those guys =
who are programming in that area&#8230;</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">Jochen</FONT>
</P>

</BODY>
</HTML>
------_=_NextPart_001_01C3EF38.89F4778C--