Modula-2 Reloaded

A Modern Typesafe & Literate Programming Notation

Site Menu

Project

Specification

Implementation

Recommendations

Reference

Needs Updating

Work in Progress

Wastebasket

Wiki Manual

edit SideBar

BCD Math

DEFINITION MODULE BCDMath;

(* Mathematical constants and functions *)

CONST
    E = 2.7182818284590452353602874713526;
    PI = 3.1415926535897932384626433832795;
    PHI = 1.6180339887498948482045868343656;

PROCEDURE sgn( r : BCD ) : BCD;
  (* Returns the signum value of r. *)

PROCEDURE floor( r : BCD ) : BCD;
  (* Returns the floor value of r. *)

PROCEDURE ceil( r : BCD ) : BCD;
  (* Returns the ceiling value of r. *)

PROCEDURE frac( r : BCD ) : BCD;
  (* Returns the fractional part of r. *)

PROCEDURE trunc( r : BCD; n : CARDINAL ) : BCD;
  (* Returns the value of r truncated to n decimal places after the decimal point. *)

PROCEDURE round( r : BCD; n : CARDINAL ) : BCD;
  (* Returns the value of r rounded to n decimal places after the decimal point. *)

PROCEDURE power( base, exponent : BCD ) : BCD;
  (* Returns the value of base raised to the power of exponent. *)

PROCEDURE sqrt( r : BCD ) : BCD;
  (* Returns the square root of r. *)

PROCEDURE ln( r : BCD ) : BCD;
  (* Returns the natural logarithm of r. *)

PROCEDURE log( r : BCD ) : BCD;
  (* Returns the decimal logarithm of r. *)

PROCEDURE sin( r : BCD ) : BCD;
  (* Returns the sine of r. *)

PROCEDURE cos( r : BCD ) : BCD;
  (* Returns the cosine of r. *)

PROCEDURE tan( r : BCD ) : BCD;
  (* Returns the tangent of r. *)

PROCEDURE arcsin( r : REAL ) : REAL;
  (* Returns the arcsine of r. *)

PROCEDURE arccos( r : BCD ) : BCD;
  (* Returns the arccosine of r. *)

PROCEDURE arctan( r : BCD ) : BCD;
  (* Returns the arctangent of r. *)

END BCDMath.