Πέμπτη 1 Νοεμβρίου 2018

Use of Infinity (Positive and Negative)

Works in Windows and in Linux through wine.
From VB6 IDE, we didn't get the same results, where the value should be -1.#IND we get Infinite,
-1.#IND used for invalid. So from IDE we didn't get invalid value. From compiled Interpreter we get it, and this happen in linux too, using wine.
To run M2000 Interpreter in IDE - We have to load the M2000.Vbp, then run it to make the M2000.dll, then start m2000.exe to load it, You can debug the dll using breakpoints or stop on errors.





Rem : locale 1033
Module CheckIt {
      Form 66,40
      Cls 5
      Pen 14
      \\ Ensure True/False for Print boolean (else -1/0)
      \\ from m2000 console use statement Switches without Set.
      \\ use Monitor statement to see all switches.
      Set Switches "+SBL"
      IF version<9.4 then exit
      IF version=9.4 and revision<25 then exit
      Function Infinity(positive=True) {
            buffer clear inf as byte*8
            m=0x7F
            if not positive then m+=128
            return inf, 7:=m, 6:=0xF0
            =eval(inf, 0 as double)
      }
      K=Infinity(false)
      L=Infinity()
      Function TestNegativeInfinity(k) {
            =str$(k, 1033) = "-1.#INF"
      }
      Function TestPositiveInfinity(k) {
            =str$(k, 1033) = "1.#INF"
      }
      Function TestInvalid {
            =str$(Number, 1033) = "-1.#IND"
      }
      Pen 11 {Print "       True       True"}
      Print TestNegativeInfinity(K), TestPositiveInfinity(L)
      Pen 11 {Print "    -1.#INF     1.#INF    -1.#INF     1.#INF    -1.#INF     1.#INF"}
      Print K, L, K*100, L*100, K+K, L+L
      M=K/L
      Pen 11 {Print "    -1.#IND    -1.#IND       True       True" }
      Print K/L, L/K, TestInvalid(M), TestInvalid(K/L)
      M=K+L
      Pen 11 {Print "    -1.#IND    -1.#IND    -1.#IND       True       True"}
      Print M, K+L, L+K, TestInvalid(M), TestInvalid(K+L)
      Pen 11 {Print "    -1.#INF     1.#INF"}
      Print 1+K+2, 1+L+2
      Pen 11 {Print "    -1.#INF"}
      Print K-L
      Pen 11 {Print "     1.#INF"}
      Print L-K
}
Checkit

Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου

You can feel free to write any suggestion, or idea on the subject.