/* Copyright (C) 1989, Digital Equipment Corporation */ /* All rights reserved. */ /* See the file COPYRIGHT for a full description. */ /* Last modified on Wed Mar 7 04:35:14 1990 by muller */ /* This file implements the arithmetic part of the run-time system for Modula-3. */ #include #include "M3RuntimeDecls.h" #define PRIVATE static #define PUBLIC PUBLIC int _M3Runtime__Round (x) double x; { if (x >= 0) { return ((int) (x + 0.5)); } else { return ((int) (x - 0.5)); } } PUBLIC int _M3Runtime__Idiv (n, m) int n, m; { if (n < 0) { if (m < 0) { return (-n / -m); } else { if ((n % m) == 0) { return (- (-n / m)); } else { return (- (-n / m) - 1); }}} else { if (m < 0) { if ((n % m) == 0) { return (- (n / -m)); } else { return (- (n / -m) - 1); }} else { return (n / m); }} } PUBLIC int _M3Runtime__Floor (x) double x; { if (x >= 0) { return ((int) x); } else { if (x != (double)((int) x)) { return (((int) x) - 1); } else { return ((int) x); }} } PUBLIC int _M3Runtime__Ceiling (x) double x; { if (x >= 0) { if (x != (double)((int) x)) { return (((int) x) + 1); } else { return ((int) x); }} else { return ((int) x); } }