]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/m2/gm2-libs-iso/RealMath.mod
Update copyright years.
[thirdparty/gcc.git] / gcc / m2 / gm2-libs-iso / RealMath.mod
CommitLineData
1eee94d3
GM
1(* RealMath.mod implement the ISO RealMath specification.
2
83ffe9cd 3Copyright (C) 2003-2023 Free Software Foundation, Inc.
1eee94d3
GM
4Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
5
6This file is part of GNU Modula-2.
7
8GNU Modula-2 is free software; you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation; either version 3, or (at your option)
11any later version.
12
13GNU Modula-2 is distributed in the hope that it will be useful, but
14WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16General Public License for more details.
17
18Under Section 7 of GPL version 3, you are granted additional
19permissions described in the GCC Runtime Library Exception, version
203.1, as published by the Free Software Foundation.
21
22You should have received a copy of the GNU General Public License and
23a copy of the GCC Runtime Library Exception along with this program;
24see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25<http://www.gnu.org/licenses/>. *)
26
27IMPLEMENTATION MODULE RealMath ;
28
29IMPORT libm ;
30IMPORT cbuiltin ;
31
32PROCEDURE __ATTRIBUTE__ __BUILTIN__ ((__builtin_sqrt)) sqrt (x: REAL): REAL;
33 (* Returns the positive square root of x *)
34BEGIN
35 RETURN cbuiltin.sqrt(x)
36END sqrt ;
37
38PROCEDURE __ATTRIBUTE__ __BUILTIN__ ((__builtin_exp)) exp (x: REAL): REAL;
39 (* Returns the exponential of x *)
40BEGIN
41 RETURN cbuiltin.exp(x)
42END exp ;
43
44PROCEDURE __ATTRIBUTE__ __BUILTIN__ ((__builtin_log)) ln (x: REAL): REAL;
45 (* Returns the natural logarithm of x *)
46BEGIN
47 RETURN cbuiltin.log(x)
48END ln ;
49
50 (* The angle in all trigonometric functions is measured in radians *)
51
52PROCEDURE __ATTRIBUTE__ __BUILTIN__ ((__builtin_sin)) sin (x: REAL): REAL;
53 (* Returns the sine of x *)
54BEGIN
55 RETURN cbuiltin.sin(x)
56END sin ;
57
58PROCEDURE __ATTRIBUTE__ __BUILTIN__ ((__builtin_cos)) cos (x: REAL): REAL;
59 (* Returns the cosine of x *)
60BEGIN
61 RETURN cbuiltin.cos(x)
62END cos ;
63
64PROCEDURE tan (x: REAL): REAL;
65 (* Returns the tangent of x *)
66BEGIN
67 RETURN libm.tan(x)
68END tan ;
69
70PROCEDURE arcsin (x: REAL): REAL;
71 (* Returns the arcsine of x *)
72BEGIN
73 RETURN libm.asin(x)
74END arcsin ;
75
76PROCEDURE arccos (x: REAL): REAL;
77 (* Returns the arccosine of x *)
78BEGIN
79 RETURN libm.acos(x)
80END arccos ;
81
82PROCEDURE arctan (x: REAL): REAL;
83 (* Returns the arctangent of x *)
84BEGIN
85 RETURN libm.atan(x)
86END arctan ;
87
88PROCEDURE power (base, exponent: REAL): REAL;
89 (* Returns the value of the number base raised to the power exponent *)
90BEGIN
91 RETURN libm.pow(base, exponent)
92END power ;
93
94PROCEDURE round (x: REAL): INTEGER;
95 (* Returns the value of x rounded to the nearest integer *)
96BEGIN
97 RETURN TRUNC(x) (* hmm we could provide access to the GNU Modula-2 built-in *)
98END round ;
99
100PROCEDURE IsRMathException (): BOOLEAN;
101 (* Returns TRUE if the current coroutine is in the exceptional execution state
102 because of the raising of an exception in a routine from this module; otherwise
103 returns FALSE.
104 *)
105BEGIN
106 RETURN FALSE
107END IsRMathException ;
108
109END RealMath.