1 (* LongMath.mod implement the ISO LongMath specification.
3 Copyright (C) 2003-2024 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6 This file is part of GNU Modula-2.
8 GNU Modula-2 is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
13 GNU Modula-2 is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. *)
27 IMPLEMENTATION MODULE LongMath
;
32 PROCEDURE __ATTRIBUTE__
__BUILTIN__ ((__builtin_sqrtl
)) sqrt (x
: LONGREAL): LONGREAL;
33 (* Returns the positive square root of x *)
35 RETURN cbuiltin.
sqrtl(x
)
38 PROCEDURE __ATTRIBUTE__
__BUILTIN__ ((__builtin_expl
)) exp (x
: LONGREAL): LONGREAL;
39 (* Returns the exponential of x *)
41 RETURN cbuiltin.
expl(x
)
44 PROCEDURE __ATTRIBUTE__
__BUILTIN__ ((__builtin_logl
)) ln (x
: LONGREAL): LONGREAL;
45 (* Returns the natural logarithm of x *)
47 RETURN cbuiltin.
logl(x
)
50 (* The angle in all trigonometric functions is measured in radians *)
52 PROCEDURE __ATTRIBUTE__
__BUILTIN__ ((__builtin_sinl
)) sin (x
: LONGREAL): LONGREAL;
53 (* Returns the sine of x *)
55 RETURN cbuiltin.
sinl(x
)
58 PROCEDURE __ATTRIBUTE__
__BUILTIN__ ((__builtin_cosl
)) cos (x
: LONGREAL): LONGREAL;
59 (* Returns the cosine of x *)
61 RETURN cbuiltin.
cosl(x
)
64 PROCEDURE tan (x
: LONGREAL): LONGREAL;
65 (* Returns the tangent of x *)
70 PROCEDURE arcsin (x
: LONGREAL): LONGREAL;
71 (* Returns the arcsine of x *)
76 PROCEDURE arccos (x
: LONGREAL): LONGREAL;
77 (* Returns the arccosine of x *)
82 PROCEDURE arctan (x
: LONGREAL): LONGREAL;
83 (* Returns the arctangent of x *)
88 PROCEDURE power (base
, exponent
: LONGREAL): LONGREAL;
89 (* Returns the value of the number base raised to the power exponent *)
91 RETURN libm.
powl(base
, exponent
)
94 PROCEDURE round (x
: LONGREAL) : INTEGER;
95 (* Returns the value of x rounded to the nearest integer *)
100 PROCEDURE IsRMathException (): BOOLEAN;
101 (* Returns TRUE if the current coroutine is in the
102 exceptional execution state because of the raising
103 of an exception in a routine from this module; otherwise
108 END IsRMathException
;