-- version control marker $Id: cg10r64.occ,v 1.1 1995/10/10 13:03:34 djb1 Exp $
PROC do.REAL64 ()
  REAL64 a, b :
  SEQ
    b := 8.6 (REAL64)
    --{{{  output message
    title ("REAL64 arithmetic")
    --}}} 
    --{{{  check arithmetic operators              (R64-001 to 099)
    a := b + 2.3 (REAL64)
    check.REAL64 (a, 8.6(REAL64) + 2.3(REAL64), "R64-001")
    a := b - 2.3 (REAL64)
    check.REAL64 (a, 8.6(REAL64) - 2.3(REAL64), "R64-002")
    a := b * 2.3 (REAL64)
    check.REAL64 (a, 8.6(REAL64) * 2.3(REAL64), "R64-003")
    a := b / 2.3 (REAL64)
    check.REAL64 (a, 8.6(REAL64) / 2.3(REAL64), "R64-004")
    a := b \ 2.3 (REAL64)
    check.REAL64 (a, 8.6(REAL64) \ 2.3(REAL64), "R64-005")
    a := (- b)
    check.REAL64 (a, -8.6(REAL64), "R64-006")
    --}}} 
    --{{{  check comparison operators              (R64-200 to 299)
    a := 4.7(REAL64)
    x := a = b
    check.BOOL (x, FALSE, "R64-206")
    x := a > b
    check.BOOL (x, FALSE, "R64-207")
    x := a >= b
    check.BOOL (x, FALSE, "R64-208")
    x := a < b
    check.BOOL (x, TRUE, "R64-209")
    x := a <= b
    check.BOOL (x, TRUE, "R64-210")
    x := a <> b
    check.BOOL (x, TRUE, "R64-211")
    --}}} 
    --{{{  check conversions                       (R64-300 to 399)
    --{{{  variable declarations for conversions
    REAL64 r64 :
    REAL32 r32 :
    INT64 i64 :
    INT32 i32 :
    INT16 i16 :
    INT i :
    --}}} 
    SEQ
      --r64 := REAL64 TRUNC b
      --check.REAL64 (r64, REAL64 TRUNC 8.6(REAL64), "R64-312")
      --r64 := REAL64 ROUND b
      --check.REAL64 (r64, REAL64 ROUND 8.6(REAL64), "R64-313")
      r32 := REAL32 TRUNC b
      check.REAL32 (r32, REAL32 TRUNC 8.6(REAL64), "R64-314")
      r32 := REAL32 ROUND b
      check.REAL32 (r32, REAL32 ROUND 8.6(REAL64), "R64-315")
      i64 := INT64 TRUNC b
      check.INT64 (i64, INT64 TRUNC 8.6(REAL64), "R64-316")
      check.INT64 (i64, 8(INT64), "R64-330")
      i64 := INT64 ROUND b
      check.INT64 (i64, INT64 ROUND 8.6(REAL64), "R64-317")
      check.INT64 (i64, 9(INT64), "R64-331")
      i32 := INT32 TRUNC b
      check.INT32 (i32, INT32 TRUNC 8.6(REAL64), "R64-318")
      check.INT32 (i32, 8(INT32), "R64-332")
      i32 := INT32 ROUND b
      check.INT32 (i32, INT32 ROUND 8.6(REAL64), "R64-319")
      check.INT32 (i32, 9(INT32), "R64-333")
      i16 := INT16 TRUNC b
      check.INT16 (i16, INT16 TRUNC 8.6(REAL64), "R64-320")
      check.INT16 (i16, 8(INT16), "R64-334")
      i16 := INT16 ROUND b
      check.INT16 (i16, INT16 ROUND 8.6(REAL64), "R64-321")
      check.INT16 (i16, 9(INT16), "R64-335")
      i := INT TRUNC b
      check.INT (i, INT TRUNC 8.6(REAL64), "R64-322")
      check.INT (i, 8(INT), "R64-336")
      i := INT ROUND b
      check.INT (i, INT ROUND 8.6(REAL64), "R64-323")
      check.INT (i, 9(INT), "R64-337")
    --}}} 
    --{{{  hefty calculations                      (R64-500 to 599)
    --{{{  declarations
    REAL64 x, y, z, a, b, c, d :
    VAL n1 IS 1.0(REAL64) :
    VAL n2 IS 2.0(REAL64) :
    VAL n3 IS 3.0(REAL64) :
    VAL n4 IS 1.0(REAL64) / 3.0(REAL64) :
    VAL eight.seven IS 2097152.0(REAL64) : -- 8 to the power 7 (= 2 to the 21)
    VAL one.sixteenth IS 1.0(REAL64) / 16.0(REAL64) :
    --}}} 
    SEQ
      --{{{  initialisation
      x := 8.0(REAL64)
      y := x + x
      z := y - x
      a := 1.11111(REAL64)
      b := 2.22222(REAL64)
      c := a * 2.0(REAL64)
      --}}} 
      check.REAL64 (y, 16.0(REAL64), "R64-500")
      check.REAL64 (z,  8.0(REAL64), "R64-501")
      check.REAL64 (c,  b, "R64-502")
      check.REAL64 (((x + y) + (n3 * z)) + ((n2 * a) - b), 48.0(REAL64), "R64-503")
      check.REAL64 (x + (x + (x + (x + (x + (x + x))))), 56.0(REAL64), "R64-504")
      check.REAL64 (x * (x * (x * (x * (x * (x * x))))), eight.seven, "R64-505")
      check.REAL64 (x * (x * (n2* (y * (y * (x * x))))), eight.seven, "R64-506")
      x := 1.0 (REAL64)
      y := 3.0 (REAL64)
      d := 2.0 (REAL64)
      check.REAL64 (x / y, n4, "R64-507")
      c := ((d/(d*d)) * (d/(d*d))) * ((d/(d*d)) * (d/(d*d)))
      check.REAL64 (c, one.sixteenth, "R64-508")
      c := ((d * y) * (d * y)) * ((d * y) * (d * y))
      check.REAL64 (c, 1296.0(REAL64), "R64-509")
      c := ((((d * y) * (d * y)) * (d * y)) * (d * y)) * (d * y)
      check.REAL64 (c, 7776.0(REAL64), "R64-510")
    --}}} 
    --{{{  passing as parameters                   (R64-600 to 699)
    --{{{  copy.REAL64 and add.REAL64
    PROC copy.REAL64 (VAL REAL64 x, REAL64 y)
      y := x
    :
    PROC add.REAL64 (VAL REAL64 x, y, REAL64 z)
      z := x + y
    :
    --}}} 
    REAL64 x, y, z :
    VAL n1 IS 2.0(REAL64) :
    VAL n2 IS 500000.0(REAL64) :
    SEQ
      copy.REAL64 (n1, x)
      check.REAL64 (x, 2.0(REAL64), "R64-600")
      copy.REAL64 (n2, x)
      check.REAL64 (x, 500000.0(REAL64), "R64-601")
      y := 5.7 (REAL64)
      copy.REAL64 (y, x)
      check.REAL64 (x, 5.7(REAL64), "R64-602")
      add.REAL64 (n1, n2, x)
      check.REAL64 (x, 500002.0(REAL64), "R64-603")
      y := n1
      z := n2
      add.REAL64 (y, z, x)
      check.REAL64 (x, 500002.0(REAL64), "R64-604")
      check.REAL64 (z, 500000.0(REAL64), "R64-605")
    --}}} 
    --{{{  arrays                                  (R64-700 to 799)
    VAL n IS 1.0(REAL64) :
    VAL m IS 1.5(REAL64) :
    VAL t1 IS [n, n, n, n, m] :
    VAL t2 IS [t1, t1, t1, t1 ] :
    VAL t3 IS [t2, t2, t2 ] :
    BOOL b :
    INT x :
    REAL64 tot :
    SEQ
      check.REAL64 (t1 [0], n  , "R64-700")
      check.REAL64 (t1 [4], m, "R64-701")
      check.REAL64 (t2 [2] [4], m, "R64-702")
      check.REAL64 (t3 [1] [2] [4], m, "R64-703")
      --{{{  test individual access                (R64-704 to 705)
      b := TRUE
      x := 4
      tot := 0.0(REAL64)
      SEQ i = 0 FOR SIZE t3
        SEQ j = 0 FOR SIZE t2
          SEQ k = 0 FOR SIZE t1
            SEQ
              IF
                (k = 4) AND (t3 [i] [j] [k] = m)
                  SKIP
                (k < 4) AND (t3 [i] [j] [k] = n)
                  SKIP
                TRUE
                  b := FALSE
              tot := tot + t3 [i] [j] [k]
              x := INT ROUND t3 [i] [j] [x]      -- sets it to 1
              x := 4                       -- resets it again
      check.BOOL (b, TRUE, "R64-704")
      VAL correct.value IS (48.0(REAL64) * n) + (12.0(REAL64) * m) :
      check.REAL64 (tot, correct.value, "R64-705")
      --}}} 
      --{{{  test nested array access              (R64-706 to 707)
      INT a, b, c :
      SEQ
        a := 2
        b := 1
        c := 3
        tot := t3[a][b][c] + ( t3[b][a][c] + ( t3[0][1][4] + ( t3[b][a+b][b+(a+b)] +
               t1[(a+b)+b] ) ) )
        VAL correct.value IS (2.0(REAL64) * n) + (3.0(REAL64) * m) :
        check.REAL64 (tot, correct.value, "R64-706")
        tot := t3 [a] [ INT ROUND t3 [a] [b] [INT ROUND t3 [b +
                        b] [a + b] [b + (a + b)] ] ] [(INT ROUND t3 [a] [c] [c +
                        (b - a)]) + (3 * (INT ROUND t3 [a] [c] [b])) ]
        check.REAL64 (tot, m, "R64-707")
      --}}} 
      --{{{  test individual access using aliasing (R64-708 to 709)
      b := TRUE
      x := 4
      tot := 0.0(REAL64)
      SEQ i = 0 FOR SIZE t3
        VAL a2 IS t3 [i] :
        SEQ j = 0 FOR SIZE t2
          VAL a1 IS a2 [j] :
          SEQ k = 0 FOR SIZE t1
            VAL a0 IS a1 [k] :
            SEQ
              IF
                (k = 4) AND (a0 = m)
                  SKIP
                (k < 4) AND (a0 = n)
                  SKIP
                TRUE
                  b := FALSE
              tot := tot + a0
              x := INT ROUND a1 [x]              -- sets it to 1
              x := 4                       -- resets it again
      check.BOOL (b, TRUE, "R64-708")
      VAL correct.value IS (48.0(REAL64) * n) + (12.0(REAL64) * m) :
      check.REAL64 (tot, correct.value, "R64-709")
      --}}} 
      --{{{  test livermore loop                   (R64-710 to 711)
      VAL n IS 10 :
      VAL r IS 7.0(REAL64) :
      VAL t IS 13.0(REAL64) :
      [n + 6] REAL64 u :
      [n] REAL64 x, y, z :
      SEQ
        SEQ k = 0 FOR n + 6
          u [k] := 3.0(REAL64)
        SEQ k = 0 FOR n
          SEQ
            y [k] := 11.0(REAL64)
            z [k] :=  5.0(REAL64)
      
        SEQ k = 0 FOR n
          x [k] := u[k] + ((( r * (z[k] + (r * y[k]))) +
                            (t * ((u[k+3] + (r * (u[k+2] + (r * u[k+1]))))))) +
                            (t * ((u[k+6] + (r * (u[k+5] + (r * u[k+4])))))))
      
        check.REAL64 (x[0],     5023.0(REAL64), "R64-710")
        check.REAL64 (x[n - 1], 5023.0(REAL64), "R64-711")
      --}}} 
      --{{{  test some bugs that were found        (R64-712 to 716)
      --{{{  bug1                                  (R64-712)
      [2][2]REAL64 arr :
      REAL64 A :
      INT i :
      SEQ
        i := 0
        arr[i][i] := 0.0(REAL64)
        A := ((arr[i][i]+arr[i][i]) + (arr[i][i]+arr[i][i])) / 4.0(REAL64)
        check.REAL64 (A, 0.0(REAL64), "R64-712")
      --}}} 
      --{{{  bug3                                  (R64-713 to 714)
      PROC Complex.Subst ([]REAL64 a, b)
        SEQ
          check.REAL64 (a[0], 2.0(REAL64), "R64-713")
          check.REAL64 (b[1], 4.0(REAL64), "R64-714")
      :
      
      [2][2][2]REAL64 g.plus, g.minus :
      REAL64 i, j :
      SEQ
        i := 1.0(REAL64)
        j := 0.0(REAL64)
        g.plus [INT ROUND i][INT ROUND j][0] := 2.0(REAL64)
        g.minus[INT ROUND i][INT ROUND j][1] := 4.0(REAL64)
        Complex.Subst (g.plus[INT ROUND i][INT ROUND j],
                       g.minus[INT ROUND i][INT ROUND j])
      --}}} 
      --{{{  bug4                                  (R64-715)
      [10][10]REAL64 c, b :
      INT i :
      REAL64 A:
      SEQ
        i := 1
        SEQ i = 0 FOR 10
          SEQ j = 0 FOR 10
            VAL tmp IS REAL64 ROUND j :
            c [i][j] := tmp
        A := ((c[i][i] * c [i*i][i+2])) / (c[(i*i)+i][(i*i)+i] + c[i][i])
        check.REAL64 (A, 1.0(REAL64), "R64-715")
      --}}} 
      --{{{  test2                                 (R64-716)
      REAL64 u :
      [4] REAL64 ai :
      [3] [4] REAL64 x, Gb :
      INT i, j, k :
      SEQ
        SEQ i = 0 FOR 4
          SEQ
            ai [i] := 5.0(REAL64)
            SEQ j = 0 FOR 3
              SEQ
                x [j] [i] := 2.0(REAL64)
                Gb[j] [i] := 24.0(REAL64)
        u := 4.0(REAL64)
        i := 1
        j := 2
        k := 3
        u := u + (ai [j] * x [j][k])
        x [i][k] := (Gb [i][k] - u) / ai[i]
        check.REAL64 (x [i][k], 2.0(REAL64), "R64-716")
      --}}} 
      --}}} 
    --}}} 
    --{{{  more conversion tests
    INT FUNCTION id(VAL INT i) IS i :
    VAL n IS 5 :
    VAL m IS 7 :
    [n][m]INT64 i64arr :
    [n][m]INT32 i32arr :
    [n][m]INT16 i16arr :
    [n][m]INT   iarr :
    [n][m]REAL32 r32arr :
    [n][m]REAL64 r64arr :
    INT i, j :
    VAL ans IS (n / 2) + (m / 2) :
    SEQ
      i, j := n / 2, m / 2
      SEQ k = 0 FOR n
        SEQ l = 0 FOR m
          r64arr[k][l] := REAL64 ROUND (k + l)
    
      r64arr[i][j] := REAL64 ROUND r64arr[i][j]
      check.REAL64(r64arr[i][j], REAL64 ROUND ans, "R64-R64-1")
      r64arr[id(i)][j] := REAL64 ROUND r64arr[id(i)][j]
      check.REAL64(r64arr[i][j], REAL64 ROUND ans, "R64-R64-2")
      r64arr[i][j] := REAL64 TRUNC r64arr[i][j]
      check.REAL64(r64arr[i][j], REAL64 TRUNC ans, "R64-R64-3")
      r64arr[id(i)][j] := REAL64 TRUNC r64arr[id(i)][j]
      check.REAL64(r64arr[i][j], REAL64 TRUNC ans, "R64-R64-4")
    
      r32arr[i][j] := REAL32 ROUND r64arr[i][j]
      check.REAL32(r32arr[i][j], REAL32 ROUND ans, "R64-R32-1")
      r32arr[id(i)][j] := REAL32 ROUND r64arr[id(i)][j]
      check.REAL32(r32arr[i][j], REAL32 ROUND ans, "R64-R32-2")
      r32arr[i][j] := REAL32 TRUNC r64arr[i][j]
      check.REAL32(r32arr[i][j], REAL32 TRUNC ans, "R64-R32-3")
      r32arr[id(i)][j] := REAL32 TRUNC r64arr[id(i)][j]
      check.REAL32(r32arr[i][j], REAL32 TRUNC ans, "R64-R32-4")
    
      i64arr[i][j] := INT64 ROUND r64arr[i][j]
      check.INT64(i64arr[i][j], INT64 ans, "R64-I64-1")
      i64arr[id(i)][j] := INT64 ROUND r64arr[id(i)][j]
      check.INT64(i64arr[i][j], INT64 ans, "R64-I64-2")
      i64arr[i][j] := INT64 TRUNC r64arr[i][j]
      check.INT64(i64arr[i][j], INT64 ans, "R64-I64-3")
      i64arr[id(i)][j] := INT64 TRUNC r64arr[id(i)][j]
      check.INT64(i64arr[i][j], INT64 ans, "R64-I64-4")
    
      i32arr[i][j] := INT32 ROUND r64arr[i][j]
      check.INT32(i32arr[i][j], INT32 ans, "R64-I32-1")
      i32arr[id(i)][j] := INT32 ROUND r64arr[id(i)][j]
      check.INT32(i32arr[i][j], INT32 ans, "R64-I32-2")
      i32arr[i][j] := INT32 TRUNC r64arr[i][j]
      check.INT32(i32arr[i][j], INT32 ans, "R64-I32-3")
      i32arr[id(i)][j] := INT32 TRUNC r64arr[id(i)][j]
      check.INT32(i32arr[i][j], INT32 ans, "R64-I32-4")
    
      i16arr[i][j] := INT16 ROUND r64arr[i][j]
      check.INT16(i16arr[i][j], INT16 ans, "R64-I16-1")
      i16arr[id(i)][j] := INT16 ROUND r64arr[id(i)][j]
      check.INT16(i16arr[i][j], INT16 ans, "R64-I16-2")
      i16arr[i][j] := INT16 TRUNC r64arr[i][j]
      check.INT16(i16arr[i][j], INT16 ans, "R64-I16-3")
      i16arr[id(i)][j] := INT16 TRUNC r64arr[id(i)][j]
      check.INT16(i16arr[i][j], INT16 ans, "R64-I16-4")
    
      iarr[i][j] := INT ROUND r64arr[i][j]
      check.INT(iarr[i][j], INT ans, "R64-INT-1")
      iarr[id(i)][j] := INT ROUND r64arr[id(i)][j]
      check.INT(iarr[i][j], INT ans, "R64-INT-2")
      iarr[i][j] := INT TRUNC r64arr[i][j]
      check.INT(iarr[i][j], INT ans, "R64-INT-3")
      iarr[id(i)][j] := INT TRUNC r64arr[id(i)][j]
      check.INT(iarr[i][j], INT ans, "R64-INT-4")
    
    --}}}
    --{{{  bug 251
    -- bug 251 from buglist
    VAL xr IS 8.6157349597130242515E+1(REAL64) :
    VAL yr IS 4.1066306682575781263E+1(REAL64) :
    VAL xi IS #40558A12040B6DA5(INT64) :
    VAL yi IS #4044887CBCC495A9(INT64) :
    VAL REAL64 xir RETYPES xi :
    VAL REAL64 yir RETYPES yi :
    REAL64 x, y :
    SEQ
      x, y := xr, yr
      check.REAL64(xr, xir, "B251a")
      check.REAL64(yr, yir, "B251b")
      check.REAL64(x,  xir, "B251c")
      check.REAL64(y,  yir, "B251d")
      VAL INT64 xx RETYPES x :
      check.INT64(xx, xi, "B251e")
      VAL INT64 yy RETYPES y :
      check.INT64(yy, yi, "B251f")
    --}}}
    --{{{  bug 739
    PROC bug.739()
      INT FUNCTION f(VAL INT i) IS i :
      INT FUNCTION fr(VAL REAL64 r)
        REAL64 temp :
        VALOF
          SEQ
            temp := r
            -- saturate the FPU stack
            temp := ((r + temp) + (r - temp)) + ((r * temp) + (r + temp))
          RESULT INT ROUND r
      :
      INT64 i64 :
      [2]INT64 a64 :
      INT32 i32 :
      [2]INT32 a32 :
      INT i :
      REAL64 r64, r1, r2 :
      VAL ans64 IS 100(INT64) :
      VAL ans32 IS 100(INT32) :
      SEQ
        i := 1
        r1, r2, r64 := 1.0(REAL64), 1.0(REAL64), 99.9(REAL64)
        i64 := INT64 ROUND r64
        check.INT64(i64,    ans64, "B739da")
        a64[i] := INT64 ROUND r64
        check.INT64(a64[1], ans64, "B739db")
        a64[f(i)] := INT64 ROUND r64
        check.INT64(a64[1], ans64, "B739dc")
        a64[fr(r1)] := INT64 ROUND r64
        check.INT64(a64[1], ans64, "B739dd")
        a64[INT ROUND ((r1+r2)-(r2+r1))] := INT64 ROUND r64
        check.INT64(a64[0], ans64, "B739de")
    
        i32 := INT32 ROUND r64
        check.INT32(i32,    ans32, "B739df")
        a32[i] := INT32 ROUND r64
        check.INT32(a32[1], ans32, "B739dg")
        a32[f(i)] := INT32 ROUND r64
        check.INT32(a32[1], ans32, "B739dh")
        a32[fr(r1)] := INT32 ROUND r64
        check.INT32(a32[1], ans32, "B739di")
        a32[INT ROUND ((r1+r2)-(r2+r1))] := INT32 ROUND r64
        check.INT32(a32[0], ans32, "B739dj")
    :
    bug.739()
    --}}}
    --{{{  bug 1206
    PROC bug.1206()
      INT i, j :
      REAL64 r :
      BOOL b :
      SEQ
        b := TRUE
        i := 88
        r := 77.0(REAL64)
        WHILE b
          SEQ
            -- this MUST be the first statement in a "basic block"!
            j := i + (INT ROUND r)
            -- The bug would turn the value i into either 0 or 1.
    
            b := FALSE
        check(j, 165, "B1206-4")
    :
    bug.1206()
    --}}}
    --{{{  bug 1405
    PROC bug.1405()
      VAL REAL64 KA IS 1.0(REAL64) :
      REAL64 x,y :
      REAL64 w03 :
      SEQ
        x,y := KA, KA
        w03 :=   ( ((KA*x)*y) - (x*KA) ) +( (x*x)   + (y*y)  )
        check.REAL64(w03, 2.0(REAL64), "B1405a64")  
    :
    bug.1405()
    --}}}
    --{{{  bug 1632
    PROC bug.1632()
      
      REAL64 a,b,c,e,f,g,h,two,result:
    
      SEQ
    
        a := 1.0 (REAL64)
        b := 3.0 (REAL64)
        c := 5.0 (REAL64)
        --d := 3.0 (REAL64)
        e := 1.0 (REAL64)
        f := 5.0 (REAL64)
        g := 1.0 (REAL64)
        h := 1.0 (REAL64)
        two := 2.0 (REAL64)
    
        result :=
        (( (-two)*c) * ((c+b)-a)) *
        ((((-two)*c) + (g*e)) - ((two*h)*f))
    
        check.REAL64(result, 1330.0(REAL64), "B1632a")
    :
    bug.1632()
    
    --}}}
    --{{{  bug INSdi02195
    PROC bug.INSdi02195()
      --{{{  functions
      BOOL   FUNCTION BOOL.fn   (VAL INT x) IS BOOL  x :
      BYTE   FUNCTION BYTE.fn   (VAL INT x) IS BYTE  x :
      INT16  FUNCTION INT16.fn  (VAL INT x) IS INT16 x :
      INT    FUNCTION INT.fn    (VAL INT x) IS x :
      INT32  FUNCTION INT32.fn  (VAL INT x) IS INT32 x :
      INT64  FUNCTION INT64.fn  (VAL INT x) IS INT64 x :
      REAL32 FUNCTION REAL32.fn (VAL INT x) IS REAL32 ROUND x :
      REAL64 FUNCTION REAL64.fn (VAL INT x) IS REAL64 ROUND x :
      --}}}
      --{{{  variables
      BOOL bool.var :
      BYTE byte.var :
      INT16 i16.var :
      INT32 i32.var :
      INT64 i64.var :
      INT   int.var :
      REAL32 r32.var :
      REAL64 r64.var :
      INT zero, int :
      --}}}
      REAL64 local.i, local.j, local.k :
      SEQ
        zero := id(0)
        int := id(77)
        --{{{  REAL64 var -> type -> REAL64         00 - 09
        local.j := id.REAL64(1.0(REAL64))
        
        --local.i := REAL64 ROUND (BOOL ROUND local.j)
        --check.REAL64(local.i, 1.0(REAL64), "REAL64-00")
        
        local.j := id.REAL64(77.0(REAL64))
        
        --local.i := REAL64 ROUND (BYTE ROUND local.j)
        --check.REAL64(local.i, 77.0(REAL64), "REAL64-01")
        local.i := REAL64 ROUND (INT ROUND local.j)
        check.REAL64(local.i, 77.0(REAL64), "REAL64-02")
        local.i := REAL64 ROUND (INT16 ROUND local.j)
        check.REAL64(local.i, 77.0(REAL64), "REAL64-03")
        local.i := REAL64 ROUND (INT32 ROUND local.j)
        check.REAL64(local.i, 77.0(REAL64), "REAL64-04")
        local.i := REAL64 ROUND (INT64 ROUND local.j)
        check.REAL64(local.i, 77.0(REAL64), "REAL64-05")
        local.i := REAL64 ROUND (REAL32 ROUND local.j)
        check.REAL64(local.i, 77.0(REAL64), "REAL64-06")
        local.i := REAL64 ROUND (REAL64 ROUND local.j)
        check.REAL64(local.i, 77.0(REAL64), "REAL64-07")
        --}}}
        --{{{  REAL64 FUNCTION -> type -> REAL64    10 - 19
        local.j := id.REAL64(1.0(REAL64))
        
        --local.i := REAL64 ROUND (BOOL REAL64.fn(INT ROUND local.j))
        --check.REAL64(local.i, 1.0(REAL64), "REAL64-10")
        
        local.j := id.REAL64(77.0(REAL64))
        
        --local.i := REAL64 ROUND (BYTE ROUND REAL64.fn(INT ROUND local.j))
        --check.REAL64(local.i, 77.0(REAL64), "REAL64-11")
        local.i := REAL64 ROUND (INT ROUND REAL64.fn(INT ROUND local.j))
        check.REAL64(local.i, 77.0(REAL64), "REAL64-12")
        local.i := REAL64 ROUND (INT16 ROUND REAL64.fn(INT ROUND local.j))
        check.REAL64(local.i, 77.0(REAL64), "REAL64-13")
        local.i := REAL64 ROUND (INT32 ROUND REAL64.fn(INT ROUND local.j))
        check.REAL64(local.i, 77.0(REAL64), "REAL64-14")
        local.i := REAL64 ROUND (INT64 ROUND REAL64.fn(INT ROUND local.j))
        check.REAL64(local.i, 77.0(REAL64), "REAL64-15")
        local.i := REAL64 ROUND (REAL32 ROUND (REAL64.fn(INT ROUND local.j)))
        check.REAL64(local.i, 77.0(REAL64), "REAL64-16")
        local.i := REAL64 ROUND (REAL64 ROUND (REAL64.fn(INT ROUND local.j)))
        check.REAL64(local.i, 77.0(REAL64), "REAL64-17")
        --}}}
        --{{{  REAL64 exp -> type -> REAL64         20 - 29
        local.k := id.REAL64(0.0(REAL64))
        
        local.j := id.REAL64(1.0(REAL64))
        
        --local.i := REAL64 ROUND (BOOL ROUND (local.j + local.k))
        --check.REAL64(local.i, 1.0(REAL64), "REAL64-20")
        
        local.j := id.REAL64(77.0(REAL64))
        
        --local.i := REAL64 ROUND (BYTE ROUND (local.j + local.k))
        --check.REAL64(local.i, 77.0(REAL64), "REAL64-21")
        local.i := REAL64 ROUND (INT ROUND (local.j + local.k))
        check.REAL64(local.i, 77.0(REAL64), "REAL64-22")
        local.i := REAL64 ROUND (INT16 ROUND (local.j + local.k))
        check.REAL64(local.i, 77.0(REAL64), "REAL64-23")
        local.i := REAL64 ROUND (INT32 ROUND (local.j + local.k))
        check.REAL64(local.i, 77.0(REAL64), "REAL64-24")
        local.i := REAL64 ROUND (INT64 ROUND (local.j + local.k))
        check.REAL64(local.i, 77.0(REAL64), "REAL64-25")
        local.i := REAL64 ROUND (REAL32 ROUND (local.j + local.k))
        check.REAL64(local.i, 77.0(REAL64), "REAL64-26")
        local.i := REAL64 ROUND (REAL64 ROUND (local.j + local.k))
        check.REAL64(local.i, 77.0(REAL64), "REAL64-27")
        --}}}
        --{{{  type var -> REAL64                  30 - 39
        --bool.var := BOOL id(1)
        --local.i := REAL64 ROUND bool.var
        --check.REAL64(local.i, 1.0(REAL64), "REAL64-30")
        --byte.var := BYTE id(77)
        --local.i := REAL64 ROUND byte.var
        --check.REAL64(local.i, 77.0(REAL64), "REAL64-31")
        int.var := id.INT(77(INT))
        local.i := REAL64 ROUND int.var
        check.REAL64(local.i, 77.0(REAL64), "REAL64-32")
        i16.var := id.INT16(77(INT16))
        local.i := REAL64 ROUND i16.var
        check.REAL64(local.i, 77.0(REAL64), "REAL64-33")
        i32.var := id.INT32(77(INT32))
        local.i := REAL64 ROUND i32.var
        check.REAL64(local.i, 77.0(REAL64), "REAL64-34")
        i64.var := id.INT64(77(INT64))
        local.i := REAL64 ROUND i64.var
        check.REAL64(local.i, 77.0(REAL64), "REAL64-35")
        r32.var := id.REAL32(77.0(REAL32))
        local.i := REAL64 ROUND r32.var
        check.REAL64(local.i, 77.0(REAL64), "REAL64-36")
        r64.var := id.REAL64(77.0(REAL64))
        local.i := REAL64 ROUND r64.var
        check.REAL64(local.i, 77.0(REAL64), "REAL64-37")
        --}}}
        --{{{  type FUNCTION -> REAL64             40 - 49
        --local.i := REAL64 ROUND BOOL.fn(zero)
        --check.REAL64(local.i, 0.0(REAL64), "REAL64-40")
        --local.i := REAL64 ROUND BYTE.fn(int)
        --check.REAL64(local.i, 77.0(REAL64), "REAL64-41")
        local.i := REAL64 ROUND INT.fn(int)
        check.REAL64(local.i, 77.0(REAL64), "REAL64-42")
        local.i := REAL64 ROUND INT16.fn(int)
        check.REAL64(local.i, 77.0(REAL64), "REAL64-43")
        local.i := REAL64 ROUND INT32.fn(int)
        check.REAL64(local.i, 77.0(REAL64), "REAL64-44")
        local.i := REAL64 ROUND INT64.fn(int)
        check.REAL64(local.i, 77.0(REAL64), "REAL64-45")
        local.i := REAL64 ROUND REAL32.fn(int)
        check.REAL64(local.i, 77.0(REAL64), "REAL64-46")
        local.i := REAL64 ROUND REAL64.fn(int)
        check.REAL64(local.i, 77.0(REAL64), "REAL64-47")
        --}}}
        --{{{  type exp -> REAL64                  50 - 59
        --bool.var := BOOL id(1)
        --local.i := REAL64 ROUND (bool.var = bool.var)
        --check.REAL64(local.i, 1.0(REAL64), "REAL64-50")
        --byte.var := BYTE id(77)
        --local.i := REAL64 byte.var
        --check.REAL64(local.i, 77.0(REAL64), "REAL64-51")
        int.var := id.INT(77(INT))
        local.i := REAL64 ROUND (int.var + (INT   zero))
        check.REAL64(local.i, 77.0(REAL64), "REAL64-52")
        i16.var := id.INT16(77(INT16))
        local.i := REAL64 ROUND (i16.var + (INT16 zero))
        check.REAL64(local.i, 77.0(REAL64), "REAL64-53")
        i32.var := id.INT32(77(INT32))
        local.i := REAL64 ROUND (i32.var + (INT32 zero))
        check.REAL64(local.i, 77.0(REAL64), "REAL64-54")
        i64.var := id.INT64(77(INT64))
        local.i := REAL64 ROUND (i64.var + (INT64 zero))
        check.REAL64(local.i, 77.0(REAL64), "REAL64-55")
        r32.var := id.REAL32(77.0(REAL32))
        local.i := REAL64 ROUND (r32.var + (REAL32 ROUND zero))
        check.REAL64(local.i, 77.0(REAL64), "REAL64-56")
        r64.var := id.REAL64(77.0(REAL64))
        local.i := REAL64 ROUND (r64.var + (REAL64 ROUND zero))
        check.REAL64(local.i, 77.0(REAL64), "REAL64-57")
        --}}}
    :
    bug.INSdi02195()
    --}}}
    --{{{  bug INSdi02423
    PROC bug.INSdi02423()
    
      PROC CheckOverflow ( VAL REAL64 address, REAL64 result)
        result := address
      :  
    
      PROC local(VAL INT Areg, Breg, VAL REAL64 expected0, expected1, VAL []BYTE msg)
        REAL64 XBreg, XAreg, Xtimes :
        REAL64 result0, result1 :
        SEQ
          CheckOverflow ( (REAL64 ROUND Breg) * (REAL64 ROUND Areg), result0 )
          XBreg := (REAL64 ROUND Breg)
          XAreg := (REAL64 ROUND Areg)
          Xtimes := XAreg * XBreg
          CheckOverflow (Xtimes, result1)
          check.REAL64(result0, expected0, msg)
          check.REAL64(result1, expected0, msg)
    
          CheckOverflow ( (REAL64 ROUND Breg)+(REAL64 ROUND Areg), result0 )
          Xtimes := XAreg + XBreg
          CheckOverflow (Xtimes, result1)
          check.REAL64(result0, expected1, msg)
          check.REAL64(result1, expected1, msg)
      :
      SEQ
        local(    1,     2,     2.0(REAL64),  3.0(REAL64), "di2423a")
        local(    2,     1,     2.0(REAL64),  3.0(REAL64), "di2423b")
        local(   -1,     2,    -2.0(REAL64),  1.0(REAL64), "di2423c")
        local(    1,    -2,    -2.0(REAL64), -1.0(REAL64), "di2423d")
        local(   -1,     1,    -1.0(REAL64),  0.0(REAL64), "di2423e")
        local(    1,    -1,    -1.0(REAL64),  0.0(REAL64), "di2423f")
        local(    1,     0,     0.0(REAL64),  1.0(REAL64), "di2423g")
        local(    0,     1,     0.0(REAL64),  1.0(REAL64), "di2423h")
        local(    0,    -1,     0.0(REAL64), -1.0(REAL64), "di2423i")
        local(   -1,     0,     0.0(REAL64), -1.0(REAL64), "di2423j")
    :
    bug.INSdi02423()
    --}}}
    --{{{  bug INSdi02439
    PROC bug.INSdi02439()
      SEQ
        PROTOCOL CONTROL  IS  INT; REAL64 :
        CHAN OF CONTROL ControlToMonitor:
        PAR
          SEQ
            SEQ i = 0 FOR 4
              INT   ii :
              REAL64 j :
              SEQ
                ControlToMonitor ? ii; j
                check(i, INT ROUND j, "di2439a")
                check(i, ii,          "di2439b")
          SEQ i = 0 FOR 4
            ControlToMonitor ! i; REAL64 ROUND i
    :
    bug.INSdi02439()
    --}}}
    --{{{  bug INSdi03306
    PROC bug.INSdi03306()
      PROC calc(VAL REAL64 a, b, c, d, e, f, r, z)
        REAL64 t, t1, t2 :
        SEQ
          t := ((-a)*(f*c))+((a*b)*(d*e))
          check.REAL64(t, 10.0(REAL64), "di3306a")
          t := ((-r)*(f*c))+((a*b)*(d*e))
          check.REAL64(t, 10.0(REAL64), "di3306b")
          t := ((z-a)*(f*c))+((a*b)*(d*e))
          check.REAL64(t, 10.0(REAL64), "di3306c")
          t := ((z-r)*(f*c))+((a*b)*(d*e))
          check.REAL64(t, 10.0(REAL64), "di3306d")
          t1 := (a*b)*(d*e)
          t2 := (-a)*(f*c)
          t := t1 + t2
          check.REAL64(t, 10.0(REAL64), "di3306e")
          t1 := (a*b)*(d*e)
          t2 := (-r)*(f*c)
          t := t1 + t2
          check.REAL64(t, 10.0(REAL64), "di3306f")
    
      :
      REAL64 a,b,c,d,e,f,r,s,t :
      SEQ
        a := -1.0(REAL64)
        b := -1.0(REAL64)
        c :=  1.0(REAL64)
        d :=  2.0(REAL64)
        e :=  3.0(REAL64)
        f :=  4.0(REAL64)
        r := -1.0(REAL64)
        calc(id.REAL64(a), id.REAL64(b), id.REAL64(c),
             id.REAL64(d), id.REAL64(e), id.REAL64(f),
             id.REAL64(r), id.REAL64(0.0(REAL64)))
    :
    bug.INSdi03306()
    --}}}
:
do.REAL64 ()
