Math Library

The mikroBasic PRO for 8051 provides a set of library functions for floating point math handling. See also Predefined Globals and Constants for the list of predefined math constants.

Library Functions

acos

Prototype

sub function acos(dim x as real) as real

Description

The function returns the arc cosine of parameter x; that is, the value whose cosine is x. The input parameter x must be between -1 and 1 (inclusive). The return value is in radians, between 0 and Π (inclusive).

asin

Prototype

sub function asin(dim x as real) as real

Description

The function returns the arc sine of parameter x; that is, the value whose sine is x. The input parameter x must be between -1 and 1 (inclusive). The return value is in radians, between -Π/2 and Π/2 (inclusive).

atan

Prototype

sub function atan(dim arg as real) as real

Description

The function computes the arc tangent of parameter arg; that is, the value whose tangent is arg. The return value is in radians, between -Π/2 and Π/2 (inclusive).

atan2

Prototype

sub function atan2(dim y as real, dim x as real) as real

Description

This is the two-argument arc tangent function. It is similar to computing the arc tangent of y/x, except that the signs of both arguments are used to determine the quadrant of the result and x is permitted to be zero. The return value is in radians, between -Π and Π (inclusive).

ceil

Prototype

sub function ceil(dim x as real) as real

Description

The function returns value of parameter x rounded up to the next whole number.

cos

Prototype

sub function cos(dim arg as real) as real

Description

The function returns the cosine of arg in radians. The return value is from -1 to 1.

cosh

Prototype

sub function cosh(dim x as real) as real

Description

The function returns the hyperbolic cosine of x, defined mathematically as (ex+e-x)/2. If the value of x is too large (if overflow occurs), the function fails.

eval_poly

Prototype

sub function eval_poly(dim x as real, dim byref d as array[10] of real, dim n as integer) as real

Description

Function Calculates polynom for number x, with coefficients stored in d[], for degree n.

exp

Prototype

sub function exp(dim x as real) as real

Description

The function returns the value of e — the base of natural logarithms — raised to the power x (i.e. ex).

fabs

Prototype

sub function fabs(dim d as real) as real

Description

The function returns the absolute (i.e. positive) value of d.

floor

Prototype

sub function floor(dim x as real) as real

Description

The function returns the value of parameter x rounded down to the nearest integer.

frexp

Prototype

sub function frexp(dim value as real, dim byref eptr as integer) as real

Description

The function splits a floating-point value value into a normalized fraction and an integral power of 2. The return value is a normalized fraction and the integer exponent is stored in the object pointed to by eptr.

ldexp

Prototype

sub function ldexp(dim value as real, dim newexp as integer) as real

Description

The function returns the result of multiplying the floating-point number value by 2 raised to the power newexp (i.e. returns value * 2newexp).

log

Prototype

sub function log(dim x as real) as real

Description

The function returns the natural logarithm of x (i.e. loge(x)).

log10

Prototype

sub function log10(dim x as real) as real

Description

The function returns the base-10 logarithm of x (i.e. log10(x)).

modf

Prototype

sub function modf(dim val as real, dim byref iptr as real) as real

Description

The function returns the signed fractional component of val, placing its whole number component into the variable pointed to by iptr.

pow

Prototype

sub function pow(dim x as real, dim y as real) as real

Description

The function returns the value of x raised to the power y (i.e. xy).

sin

Prototype

sub function sin(dim arg as real) as real

Description

The function returns the sine of arg in radians. The return value is from -1 to 1.

sinh

Prototype

sub function sinh(dim x as real) as real

Description

The function returns the hyperbolic sine of x, defined mathematically as (ex-e-x)/2. If the value of x is too large (if overflow occurs), the function fails.

sqrt

Prototype

sub function sqrt(dim x as real) as real

Description

The function returns the non negative square root of x.

tan

Prototype

sub function tan(dim x as real) as real

Description

The function returns the tangent of x in radians. The return value spans the allowed range of floating point in mikroBasic PRO for 8051.

tanh

Prototype

sub function tanh(dim x as real) as real)

Description

The function returns the hyperbolic tangent of x, defined mathematically as sinh(x)/cosh(x).

Copyright (c) 2002-2013 mikroElektronika. All rights reserved.
What do you think about this topic ? Send us feedback!
Want more examples and libraries? 
Find them on LibStock - A place for the code