Welcome, Guest
Username: Password: Remember me
Qui si parla italiano
  • Page:
  • 1

TOPIC:

Divide by 0 29 Jan 2019 15:18 #7236

  • softdevo@tiscali.it's Avatar
  • Topic Author


  • Posts: 174
  • 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

    Please Log in or Create an account to join the conversation.

    Divide by 0 29 Jan 2019 16:01 #7237

    • Chris
    • Chris's Avatar


  • Posts: 3750
  • 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).
    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
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1
    Moderators: wriedmann