// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/12/MathTest/Main.jack

/** Test program for the OS Math class. */
class Main {

    /** Performs various mathematical operations, using calls to the Math class methods. */
    function void main() {
        var Array r;          // stores the test results;
        
        let r = 4107;
    
        let r[0] = 2 * 3;                  // 6
        let r[1] = r[0] * (-30);           // 6 * (-30) = -180
        let r[2] = r[1] * 100;             // (-180) * 100 = -18000
        let r[3] = 1 * r[2];               // 1 * (-18000) = -18000
        let r[4] = r[3] * 0;               // 0
        
        let r[0] = 9 / 3;                  // 3
        let r[1] = (-18000) / 6;           // -3000
        let r[2] = 32766 / (-32767);       // 0
        
        let r[3] = Math.sqrt(9);           // 3
        let r[4] = Math.sqrt(32767);       // 181
        
        let r[0] = Math.min(345, 123);    // 123
        let r[1] = Math.max(123, -345);   // 123
        let r[2] = Math.abs(27);          // 27
        let r[3] = Math.abs(-32767);      // 32767
        
        return;
    }
}
