Salve a tutti, dividere 0 per 0 è un errore, ma ho la sensazione che i Runtime di Vulcan gestissero l'errore e restituissero 0, mentre con i Runtime di Xsharp una divisione 0 per 0 restituiscono NaN. Sbaglio?
Grazie
Divide by 0
Moderator: wriedmann
Divide by 0
Hi Danilo,
It is easy to test this, try to compile the following code in vulcan, then in X# with vulcan runtime and then in X# with X# rutnime. In all cases, you should get NaN for both REAL8 and FLOAT, but you will get a System.DivideByZeroException for the INT division.
Apparently that's how it was designed in .Net by MS, to always throw an error in an integer division by 0, but for float numbers it either returns INF (for 123 / 0.0) or NaN (for (0.0 / 0.0).
It is easy to test this, try to compile the following code in vulcan, then in X# with vulcan runtime and then in X# with X# rutnime. In all cases, you should get NaN for both REAL8 and FLOAT, but you will get a System.DivideByZeroException for the INT division.
Apparently that's how it was designed in .Net by MS, to always throw an error in an integer division by 0, but for float numbers it either returns INF (for 123 / 0.0) or NaN (for (0.0 / 0.0).
Code: Select all
FUNCTION Start( ) AS VOID
LOCAL r := 0.0 AS REAL8
LOCAL f := 0.0 AS FLOAT
LOCAL n := 0 AS INT
? r/r
? f/f
? n/n
RETURN
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu