From fef36fd11c9d3d7f632098c5005bf0e3e5ce5ad9 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 17 Jan 2018 12:01:40 +0100 Subject: finished Screen. - a bit slow though --- projects/12/MathTest/Math.jack | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'projects/12/MathTest/Math.jack') diff --git a/projects/12/MathTest/Math.jack b/projects/12/MathTest/Math.jack index 6bac42e..01bce8f 100644 --- a/projects/12/MathTest/Math.jack +++ b/projects/12/MathTest/Math.jack @@ -28,6 +28,18 @@ class Math { return ~(x & twoToThe[i] = 0); } + function int sign(int x) { + if (x > 0) { + return 1; + } else { + if (x < 0) { + return -1; + } else { + return 0; + } + } + } + /** Returns the absolute value of x. */ function int abs(int x) { if (x > 0){ -- cgit v1.2.3