c:/Users/efeyhl/devs/math2/c_basic_math.h File Reference

defines, structs and C-functions More...

#include <stdio.h>

Go to the source code of this file.

Classes

union  BM_STATUS
 basic math status (BM_STATUS) informations More...

Defines

#define __INT64_DEFINED__
 indicates that the data type int64 now is defined
#define EXA   (1.E18)
 Multiplier for SI units.
#define PETA   (1.E15)
#define TERA   (1.E12)
#define GIGA   (1.E9)
#define MEGA   (1.E6)
#define KILO   (1.E3)
#define MILLI   (1.E-3)
#define MICRO   (1.E-6)
#define NANO   (1.E-9)
#define PICO   (1.E-12)
#define FEMTO   (1.E-15)
#define ATTO   (1.E-18)
#define ONE_DIV_3   (1.0 / 3.0)
 simple and often used constants
#define ONE_DIV_4   (1.0 / 4.0)
#define PI   (3.1415926535897932384626433832795)
 angle circular measure: radian = degree * PI / 180
#define PI1   (PI / 180.0)
#define PI18   (PI / 10.0)
#define PI20   (PI / 9.0)
#define PI30   (PI / 6.0)
#define PI36   (PI / 5.0)
#define PI40   (2.0 * PI / 9.0)
#define PI45   (PI / 4.0)
#define PI54   (3.0 * PI / 10.0)
#define PI60   (PI / 3.0)
#define PI72   (2.0 * PI / 5.0)
#define PI90   (PI / 2.0)
#define PI108   (3.0 * PI / 5.0)
#define PI120   (2.0 * PI / 3.0)
#define PI135   (3.0 * PI / 4.0)
#define PI180   (PI)
#define PI240   (2.0 * PI120)
#define PI270   (3.0 * PI / 2.0)
#define PI360   (2.0 * PI)
#define DEG1   (180.0 / PI)
#define SQRT2   (1.4142135623730950488016887242097)
#define SQRT3   (1.7320508075688772935274463415059)

Typedefs

typedef long long int64
 64 bit signed integer
typedef unsigned long long uint64
 64 bit unsigned integer

Functions

void printBM_STATUS (const BM_STATUS bms, FILE *file)
 prints a basic math status (BM_STATUS) to file
int isDouble (const double *value, BM_STATUS *bms)
 tests for a valid 64 bit floating point value (double)
int isI64 (const int64 *value, BM_STATUS *bms)
 tests for a valid 64 bit integer value (int64)
double doubleAddDouble (const double augend, const double addend, BM_STATUS *bms)
 safe addition
int64 i64AddI64 (const int64 augend, const int64 addend, BM_STATUS *bms)
 safe addition
double doubleSubDouble (const double minuend, const double subtrahend, BM_STATUS *bms)
 safe subtraction
int64 i64SubI64 (const int64 minuend, const int64 subtrahend, BM_STATUS *bms)
 safe subtraction
double doubleMulDouble (const double multiplier, const double multiplicand, BM_STATUS *bms)
 safe multiplication
int64 i64MulI64 (const int64 multiplier, const int64 multiplicand, BM_STATUS *bms)
 safe multiplication
double doubleDivDouble (const double numerator, const double denominator, BM_STATUS *bms)
 safe division
int64 i64DivI64 (const int64 numerator, const int64 denominator, BM_STATUS *bms)
 safe division
double doubleModDouble (const double numerator, const double denominator, BM_STATUS *bms)
 safe modulo
int64 i64ModI64 (const int64 numerator, const int64 denominator, BM_STATUS *bms)
 safe modulo
double reciprocDouble (const double value, BM_STATUS *bms)
 safe reciproc (1/x)
double ceilDouble (const double value, BM_STATUS *bms)
 Calculates the ceiling of value.
double floorDouble (const double value, BM_STATUS *bms)
 Calculates the floor of value.
int64 doubleToInt64 (const double value, double *intDbl, BM_STATUS *bms)
 strips the decimal places from value and returns the integer (int64)
double i64ToDouble (const int64 value)
 converts from int64 to a value in double format
double roundDouble (const double value, const int decPlaces, BM_STATUS *bms)
 rounds value to a specified number of decimal places
int doubleCompareDouble (const double value1, const double value2, const double diff, BM_STATUS *bms)
 compares value1 with value2
int i64CompareI64 (const int64 value1, const int64 value2, const int64 diff)
 compares value1 with value2
int isEvenI64 (const int64 value)
 returns 1 if value is even (.. -4, -2, 0, +2, +4, ..)
double positiveDouble (const double value, BM_STATUS *bms)
 calculates the absolute value of value
int64 positiveI64 (const int64 value, BM_STATUS *bms)
 calculates the absolute value of value
double negativeDouble (const double value, BM_STATUS *bms)
 calculates the negative absolute value of value
int64 negativeI64 (const int64 value)
 calculates the negative absolute value of value
double invertSignDouble (const double value, BM_STATUS *bms)
 inverts the sign of value
int64 invertSignI64 (const int64 value, BM_STATUS *bms)
 inverts the sign of value
double doublePow_2 (const double base, BM_STATUS *bms)
 safe square (power 2)
int64 i64Pow_2 (const int64 base, BM_STATUS *bms)
 safe square (power 2)
double doublePow_3 (const double base, BM_STATUS *bms)
 safe cube (power 3)
int64 i64Pow_3 (const int64 base, BM_STATUS *bms)
 safe cube (power 3)
double doublePow_4 (const double base, BM_STATUS *bms)
 safe power 4
int64 i64Pow_4 (const int64 base, BM_STATUS *bms)
 safe power 4
double doublePowDouble (const double base, const double exponent, BM_STATUS *bms)
 safe power, calculates base pow exponent
int64 i64PowI64 (const int64 base, const int64 exponent, BM_STATUS *bms)
 safe power, calculates base pow exponent
double doubleRoot_2 (const double radicand, BM_STATUS *bms)
 safe square root
int64 i64Root_2 (const int64 radicand, BM_STATUS *bms)
 safe square root
double doubleRoot_3 (const double radicant, BM_STATUS *bms)
 safe cube root
double doubleRoot_4 (const double radicant, BM_STATUS *bms)
 safe 4th root
double doubleRootDouble (const double radicant, const double rootExponent, BM_STATUS *bms)
 safe exp-th root
int64 i64RootI64 (const int64 radicant, const int64 rootExponent, BM_STATUS *bms)
 safe exp-th root
double doubleLogDouble (const double base, const double value, BM_STATUS *bms)
 returns the base-logarithm of value
int64 i64LogI64 (const int64 base, const int64 value, BM_STATUS *bms)
 returns the base-logarithm of value
void sortAscendantDouble (double *values, const unsigned long count, BM_STATUS *bms)
 sorts an array of values in ascendant order
void sortAscendantI64 (int64 *values, const unsigned long count)
 sorts an array of values in ascendant order
long doubleSolveP1norm (double *xr, const double *pf)
 solves the normalized polynom function of first degree
long doubleSolveP1 (double *xr, const double *pf)
 solves the polynom function of first degree
long doubleSolveP2norm (double *xr, const double *pf)
 solves the normalized polynom function of second degree
long doubleSolveP2 (double *xr, const double *pf)
 solves the polynom function of second degree
long doubleSolveP3norm (double *xr, const double *pf)
 solves the normalized polynom function of third degree
long doubleSolveP3 (double *xr, const double *pf)
 solves the polynom function of third degree
long doubleSolveP4norm (double *xr, const double *pf)
 solves the normalized polynom function of fourth degree
long doubleSolveP4 (double *xr, const double *pf)
 solves the polynom function of fourth degree
long doubleGetPolyFactors1 (double *pf, const double *xz)
 calculates the polynom factors of the given zero condition(s)
BM_STATUS doubleGetPolyFactors2 (double *pf, const double *xz)
 calculates the polynom factors of the given zero condition(s)
BM_STATUS doubleGetPolyFactors3 (double *pf, const double *xz)
 calculates the polynom factors of the given zero condition(s)
BM_STATUS doubleGetPolyFactors4 (double *pf, const double *xz)
 calculates the polynom factors of the given zero condition(s)
double deg2RadDouble (const double degree, BM_STATUS *bms)
 converts degree into radian
double rad2DegDouble (const double radian, BM_STATUS *bms)
 converts radian into degree
double stringToDouble (const char *stringValue, BM_STATUS *bms)
 converts stringValue into double
int64 stringToI64 (const char *stringValue, char **stopChar, BM_STATUS *bms)
 converts stringValue into int64
double strToDouble (const char *str, BM_STATUS *bms)
 converts a null terminated string into a 80 bit floating point value (double)
BM_STATUS doubleSolveL1 (double *xr, const double *lf)
 solves the linear equation with 1 unknown value
BM_STATUS doubleSolveL2 (double *xr, double *lf[2])
 solves the linear equations with 2 unknown values
void printDoubleBitpattern (double value, FILE *file)
 prints the bitpattern of a double value in hex format
void printDoubleBitpatternFormatted (double value, FILE *file)
 prints the formatted bitpattern of a double value (sign mantisse exponent)
double sinDouble (const double rad, BM_STATUS *bms)
 calculates the sinus of rad
double asinDouble (const double value, BM_STATUS *bms)
 calculates the arcus sinus of value [-1 .. +1]
double cosDouble (const double rad, BM_STATUS *bms)
 calculates the cosinus of rad
double acosDouble (const double value, BM_STATUS *bms)
 calculates the arcus cosinus of value [-1 .. +1]
double tanDouble (const double rad, BM_STATUS *bms)
 calculates the tangent of rad
double atanDouble (const double value, BM_STATUS *bms)
 calculates the arcus tangent of value
double cotDouble (const double rad, BM_STATUS *bms)
 calculates the cotangent of rad
double acotDouble (const double value, BM_STATUS *bms)
 calculates the arcus cotangent of value
int findDouble (const double *element1, const unsigned int count, const double elem)
 looks for a same element in the array
int findI64 (const __int64 *element1, const unsigned int count, const __int64 elem)
 looks for a same element in the array

Detailed Description

defines, structs and C-functions

This file contains all definitions, structures and C-style functions for safe basic numeric mathematical operations

Author:
Eckhardt Feyhl (2010 Nov. 13)

Define Documentation

#define ATTO   (1.E-18)

is a prefix in the metric system denoting 10^-18 or 0.000000000000000001

#define DEG1   (180.0 / PI)

1 rad converted to degree = 57.295779513082320876798154814105 deg

#define EXA   (1.E18)

Multiplier for SI units.

is a prefix in the metric system denoting 10^18 or 1000000000000000000

#define FEMTO   (1.E-15)

is a prefix in the metric system denoting 10^-15 or 0.000000000000001

#define GIGA   (1.E9)

is a prefix in the metric system denoting 10^9 or 1000000000

#define KILO   (1.E3)

is a prefix in the metric system denoting 10^3 or 1000

#define MEGA   (1.E6)

is a prefix in the metric system denoting 10^6 or 1000000

#define MICRO   (1.E-6)

is a prefix in the metric system denoting 10^-6 or 0.000001

#define MILLI   (1.E-3)

is a prefix in the metric system denoting 10^-3 or 0.001

#define NANO   (1.E-9)

is a prefix in the metric system denoting 10^-9 or 0.000000001

#define ONE_DIV_3   (1.0 / 3.0)

simple and often used constants

(1/3) as define

#define ONE_DIV_4   (1.0 / 4.0)

(1/4) as define

#define PETA   (1.E15)

is a prefix in the metric system denoting 10^15 or 1000000000000000

#define PI   (3.1415926535897932384626433832795)

angle circular measure: radian = degree * PI / 180

80 bit resolution, 32 digits

#define PI1   (PI / 180.0)

1 degree converted to radian

#define PI108   (3.0 * PI / 5.0)

108 degree converted to radian

#define PI120   (2.0 * PI / 3.0)

120 degree converted to radian

#define PI135   (3.0 * PI / 4.0)

135 degree converted to radian

#define PI18   (PI / 10.0)

18 degree converted to radian

#define PI180   (PI)

180 degree converted to radian

#define PI20   (PI / 9.0)

20 degree converted to radian

#define PI240   (2.0 * PI120)

240 degree converted to radian

#define PI270   (3.0 * PI / 2.0)

270 degree converted to radian

#define PI30   (PI / 6.0)

30 degree converted to radian

#define PI36   (PI / 5.0)

36 degree converted to radian

#define PI360   (2.0 * PI)

270 degree converted to radian

#define PI40   (2.0 * PI / 9.0)

40 degree converted to radian

#define PI45   (PI / 4.0)

45 degree converted to radian

#define PI54   (3.0 * PI / 10.0)

54 degree converted to radian

#define PI60   (PI / 3.0)

60 degree converted to radian

#define PI72   (2.0 * PI / 5.0)

72 degree converted to radian

#define PI90   (PI / 2.0)

90 degree converted to radian

#define PICO   (1.E-12)

is a prefix in the metric system denoting 10^-12 or 0.000000000001

#define SQRT2   (1.4142135623730950488016887242097)

sqrt(2.0)

#define SQRT3   (1.7320508075688772935274463415059)

sqrt(3.0)

#define TERA   (1.E12)

is a prefix in the metric system denoting 10^12 or 1000000000000


Function Documentation

double acosDouble ( const double  value,
BM_STATUS bms 
)

calculates the arcus cosinus of value [-1 .. +1]

result = acos( value )

Parameters:
value [-1 .. +1]
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of this operation in double format
The result will be in range of [0 .. +PI]
bms->trigonArcErr will be set if value is out of range.
If value < -1.0 this function returns PI
If value > +1.0 this function returns 0
See also:
sinDouble(), cosDouble(), tanDouble(), cotDouble()
asinDouble(), acosDouble(), atanDouble(), acotDouble()
rad2DegDouble(), deg2RadDouble()
double acotDouble ( const double  value,
BM_STATUS bms 
)

calculates the arcus cotangent of value

result = acot( value );

Parameters:
value [in] the value for this calculation
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of this operation in double format
The result will be in range of [0 .. +PI]
Hint:
Calculation:
if value < 0
result = acot( value ) = atan2( 1, value ) + PI
if value >= 0
result = acot( value ) = atan2( 1, value )
See also:
sinDouble(), cosDouble(), tanDouble(), cotDouble()
asinDouble(), acosDouble(), atanDouble(), acotDouble()
rad2DegDouble(), deg2RadDouble()
double asinDouble ( const double  value,
BM_STATUS bms 
)

calculates the arcus sinus of value [-1 .. +1]

result = asin( value )

Parameters:
value [-1 .. +1]
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of this operation in double format
The result will be in range of [-PI/2 .. +PI/2]
bms->trigonArcErr will be set if value is out of range.
If value < -1.0 this function returns -PI/2
If value > +1.0 this function returns +PI/2
See also:
sinDouble(), cosDouble(), tanDouble(), cotDouble()
asinDouble(), acosDouble(), atanDouble(), acotDouble()
rad2DegDouble(), deg2RadDouble()
double atanDouble ( const double  value,
BM_STATUS bms 
)

calculates the arcus tangent of value

result = atan( value )

Parameters:
value [-DBL_MAX .. +DBL_MAX]
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of this operation in double format
The result will be in range of ]-PI/2 .. +PI/2[
See also:
sinDouble(), cosDouble(), tanDouble(), cotDouble()
asinDouble(), acosDouble(), atanDouble(), acotDouble()
rad2DegDouble(), deg2RadDouble()
double ceilDouble ( const double  value,
BM_STATUS bms 
)

Calculates the ceiling of value.

Calculates the smallest integer that is greater than or equal to value

Parameters:
value [in] the value for this calculation
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the integer value in double format
The result will be in range of [ -DBL_MAX .. +DBL_MAX ]
Hint:
This method uses the standard C function ceil().
Examples:
double value = 2.1;
double result = ceilDouble(value,0);
printf("\n ceil of %f = %f", value, result);
value = -2.9;
result = ceilDouble(value,0);
printf("\n ceil of %f = %f", value, result);
Outputs:
ceil of 2.1 = 3.0
ceil of -2.9 = -2.0
double cosDouble ( const double  rad,
BM_STATUS bms 
)

calculates the cosinus of rad

result = cos( rad )

Parameters:
rad the angle [-DBL_MAX .. +DBL_MAX]
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of this operation in double format
The result will be in range of [-1 .. +1]
Hint:
the parameter rad will be interpreted in rad (circular measure).
See also:
sinDouble(), cosDouble(), tanDouble(), cotDouble()
asinDouble(), acosDouble(), atanDouble(), acotDouble()
rad2DegDouble(), deg2RadDouble()
double cotDouble ( const double  rad,
BM_STATUS bms 
)

calculates the cotangent of rad

result = cos( rad ) / sin( rad ) = 1 / tan( rad )

Parameters:
rad [in] the value for this calculation
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of this operation in double format
The result will be in range of [ -DBL_MAX .. +DBL_MAX ]
Hint:
rad will be interpreted in rad (circular measure).
rad must be in range of [ -DBL_MAX .. +DBL_MAX ]
except the values [k*pi (for k element N)]

if sin( rad ) = 0 then the status bit trigonCotErr will also be set
See also:
sinDouble(), cosDouble(), tanDouble(), cotDouble()
asinDouble(), acosDouble(), atanDouble(), acotDouble()
rad2DegDouble(), deg2RadDouble()
double deg2RadDouble ( const double  degree,
BM_STATUS bms 
)

converts degree into radian

rad = (degree / 180) * pi

Parameters:
degree [in] the degree value
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the radian value
double doubleAddDouble ( const double  augend,
const double  addend,
BM_STATUS bms 
)

safe addition

adds addend to augend and returns the result of this operation

Parameters:
augend [in] the first value for this operation
addend [in] the second value for this operation
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of augend + addend (add)
int doubleCompareDouble ( const double  value1,
const double  value2,
const double  diff,
BM_STATUS bms 
)

compares value1 with value2

Parameters:
value1 the 64 bit floating point value
value2 the second value to be compared with value1
diff minimum difference to detect equality
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
-3, if diff is not a valid value -2, if value1 or value2 or both values are invalid (nan)
-1, if value1 is less than value2
0, if value1 is equal with value2
+1, if value1 is greater than value2
double doubleDivDouble ( const double  numerator,
const double  denominator,
BM_STATUS bms 
)

safe division

divides numerator with denominator and returns the result of this operation

Parameters:
numerator [in] the first value for this operation
denominator [in] the second value for this operation
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of numerator / denominator (div)
long doubleGetPolyFactors1 ( double *  pf,
const double *  xz 
)

calculates the polynom factors of the given zero condition(s)

solves (x - xz[0]) = 0 -->> pf[0] = -xz[0]

Parameters:
pf [out] result for the polynom factor(s)
pf[0] = offset
xz [in] zero condition(s) for the polynom
Returns:
0 if all is OK
BM_STATUS doubleGetPolyFactors2 ( double *  pf,
const double *  xz 
)

calculates the polynom factors of the given zero condition(s)

solves (x - xz[1])*(x - xz[0]) = 0 -->> pf[0,1]

Parameters:
pf [out] result for the polynom factor(s)
pf[0] = offset
pf[1] = x-factor
xz [in] zero condition(s) for the polynom
Returns:
0 if all is OK
BM_STATUS doubleGetPolyFactors3 ( double *  pf,
const double *  xz 
)

calculates the polynom factors of the given zero condition(s)

solves (x - xz[2])*(x - xz[1])*(x - xz[0]) = 0 -->> pf[0,1,2]

Parameters:
pf [out] result for the polynom factor(s)
pf[0] = offset
pf[1] = x-factor
pf[2] = x^2-factor
xz [in] zero condition(s) for the polynom
Returns:
0 if all is OK
BM_STATUS doubleGetPolyFactors4 ( double *  pf,
const double *  xz 
)

calculates the polynom factors of the given zero condition(s)

solves (x - xz[3])*(x - xz[2])*(x - xz[1])*(x - xz[0]) = 0 -->> pf[0,1,2,3]

Parameters:
pf [out] result for the polynom factor(s)
pf[0] = offset
pf[1] = x-factor
pf[2] = x^2-factor
pf[3] = x^3-factor
xz [in] zero condition(s) for the polynom
Returns:
0 if all is OK
double doubleLogDouble ( const double  base,
const double  value,
BM_STATUS bms 
)

returns the base-logarithm of value

the log-function solves the equation
base pow result = value
and returns result in double format

Parameters:
base the base of the logarithm (useful >= 2)
value the logarithm's result
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the power to base so that base pow result = value
The result will be in range of [ -DBL_MAX .. +DBL_MAX ]
See also:
doubleRootDouble(), doubleRoot_2(),
doublePowDouble(), logDouble()
double doubleModDouble ( const double  numerator,
const double  denominator,
BM_STATUS bms 
)

safe modulo

divides numerator with denominator and returns the remainder as result of this operation

Parameters:
numerator [in] the first value for this operation
denominator [in] the second value for this operation
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of numerator % denominator (modulo)
Hint
if denominator is 0 (divide by zero), numerator will be returned and in bms the status bit divideZero and overflow will be set (no modulo active).
double doubleMulDouble ( const double  multiplier,
const double  multiplicand,
BM_STATUS bms 
)

safe multiplication

multiplies multiplier with multiplicand and returns the result of this operation

Parameters:
multiplier [in] the first value for this operation
multiplicand [in] the second value for this operation
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of multiplier * multiplicand (mul)
double doublePow_2 ( const double  base,
BM_STATUS bms 
)

safe square (power 2)

calculates base raised to the power of 2 and returns the result of this operation

Parameters:
base [in] the base value for this operation
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of base ^ 2 (pow)
double doublePow_3 ( const double  base,
BM_STATUS bms 
)

safe cube (power 3)

calculates base raised to the power of 3 and returns the result of this operation

Parameters:
base [in] the base value for this operation
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of base ^ 3 (pow)
double doublePow_4 ( const double  base,
BM_STATUS bms 
)

safe power 4

calculates base raised to the power of 4 and returns the result of this operation

Parameters:
base [in] the base value for this operation
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of base ^ 4 (pow)
double doublePowDouble ( const double  base,
const double  exponent,
BM_STATUS bms 
)

safe power, calculates base pow exponent

calculates base raised to the power of exponent and returns the result of this operation

Parameters:
base [in] the base value for this operation
exponent [in] the exponent value for this operation
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of base ^ exponent (pow)
The result will be in range of [ -DBL_MAX .. +DBL_MAX ]
See also:
doubleRootDouble(), sqrtDouble(), logDouble()
double doubleRoot_2 ( const double  radicand,
BM_STATUS bms 
)

safe square root

calculates the square root of radicand and returns the result of this operation

Parameters:
radicand [in] the value for this operation
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
if radicand >= 0 : sqrt( radicand )
if radicand < 0 : -sqrt( fabs( radicand ) ) and bms->negRadicand will be set
double doubleRoot_3 ( const double  radicant,
BM_STATUS bms 
)

safe cube root

calculates the cube root of radicant and returns the result of this operation

Parameters:
radicant [in] the value for this operation
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of root3( radicant )
double doubleRoot_4 ( const double  radicant,
BM_STATUS bms 
)

safe 4th root

calculates the 4th root of radicant and returns the result of this operation

Parameters:
radicant [in] the value for this operation
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of root4( radicant )
double doubleRootDouble ( const double  radicant,
const double  rootExponent,
BM_STATUS bms 
)

safe exp-th root

calculates the exp-th root of radicant and returns the result of this operation

Parameters:
radicant [in] the value for this operation
rootExponent [in] the exponent of the root
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of root-exp( radicant )
BM_STATUS doubleSolveL1 ( double *  xr,
const double *  lf 
)

solves the linear equation with 1 unknown value

equation lf[1] * xr[0] - lf[0] = 0 will be solved for xr[0] = lf[0] / lf[1]

Parameters:
xr [out] the result(s) of the linear equation(s)
lf [in] the linear factors of the equation
Returns:
the number of solutions written to xr
and in xr the result(s) for the unknown variable(s)
BM_STATUS doubleSolveL2 ( double *  xr,
double *  lf[2] 
)

solves the linear equations with 2 unknown values

equation 1: lf[0][2] * b + lf[0][1] * a = lf[0][0]
equation 1: lf[1][2] * b + lf[1][1] * a = lf[1][0]
-->> xr[0] = result for a
-->> xr[1] = result for b

Parameters:
xr [out] the result(s) of the linear equation(s)
lf [in] the linear factors of the equation
Returns:
the number of solutions written to xr
and in xr the result(s) for the unknown variable(s)
long doubleSolveP1 ( double *  xr,
const double *  pf 
)

solves the polynom function of first degree

solves pf[1]*x + pf[0] = 0 -->> xr[0] = -pf[0] / pf[1]

Parameters:
xr [out] pointer to store the solution(s)
pf [in] polynom factor(s)
Returns:
the number of solutions and the result(s) for x in xr
long doubleSolveP1norm ( double *  xr,
const double *  pf 
)

solves the normalized polynom function of first degree

solves x + pf[0] = 0 -->> xr[0] = -pf[0]

Parameters:
xr [out] pointer to store the solution(s)
pf [in] polynom factor(s)
Returns:
the number of solutions and the result(s) for x in xr
long doubleSolveP2 ( double *  xr,
const double *  pf 
)

solves the polynom function of second degree

solves pf[2]*x^2 + pf[1]*x + pf[0] = 0 -->> xr[0,1]

Parameters:
xr [out] pointer to store the solution(s)
the solution values are stored in ascendant order
pf [in] polynom factor(s)
Returns:
the number of solutions and the result(s) for x in xr
long doubleSolveP2norm ( double *  xr,
const double *  pf 
)

solves the normalized polynom function of second degree

solves x^2 + pf[1]*x + pf[0] = 0 -->> xr[0,1]

Parameters:
xr [out] pointer to store the solution(s)
the solution values are stored in ascendant order
pf [in] polynom factor(s)
Returns:
the number of solutions and the result(s) for x in xr
long doubleSolveP3 ( double *  xr,
const double *  pf 
)

solves the polynom function of third degree

solves pf[3]*x^3 + pf[2]*x^2 + pf[1]*x + pf[0] = 0 -->> xr[0,1,2]

Parameters:
xr [out] pointer to store the solution(s)
the solution values are stored in ascendant order
pf [in] polynom factor(s)
Returns:
the number of solutions and the result(s) for x in xr
long doubleSolveP3norm ( double *  xr,
const double *  pf 
)

solves the normalized polynom function of third degree

solves x^3 + pf[2]*x^2 + pf[1]*x + pf[0] = 0 -->> xr[0,1,2]

Parameters:
xr [out] pointer to store the solution(s)
the solution values are stored in ascendant order
pf [in] polynom factor(s)
Returns:
the number of solutions and the result(s) for x in xr
long doubleSolveP4 ( double *  xr,
const double *  pf 
)

solves the polynom function of fourth degree

solves pf[4]*x^4 + pf[3]*x^3 + pf[2]*x^2 + pf[1]*x + pf[0] = 0 -->> xr[0,1,2,3]

Parameters:
xr [out] pointer to store the solution(s)
the solution values are stored in ascendant order
pf [in] polynom factor(s)
Returns:
the number of solutions and the result(s) for x in xr
long doubleSolveP4norm ( double *  xr,
const double *  pf 
)

solves the normalized polynom function of fourth degree

solves x^4 + pf[3]*x^3 + pf[2]*x^2 + pf[1]*x + pf[0] = 0 -->> xr[0,1,2,3]

Parameters:
xr [out] pointer to store the solution(s)
the solution values are stored in ascendant order
pf [in] polynom factor(s)
Returns:
the number of solutions and the result(s) for x in xr
double doubleSubDouble ( const double  minuend,
const double  subtrahend,
BM_STATUS bms 
)

safe subtraction

subtracts subtrahend from minuend and returns the result of this operation

Parameters:
minuend [in] the first value for this operation
subtrahend [in] the second value for this operation
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of minuend - subtrahend (sub)
int64 doubleToInt64 ( const double  value,
double *  intDbl,
BM_STATUS bms 
)

strips the decimal places from value and returns the integer (int64)

Extracts the integer part from value

Parameters:
value [in] the value which will be converted from double to int64
intDbl [out,opt] (can be null) A pointer to a double to receive the integer in double format.
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the integer part of value in range of [LLONG_MIN .. LLONG_MAX] in int64 format.
in intDbl the integer part of value in double format
The result will be in range of [ -DBL_MAX .. +DBL_MAX ]
Hint:
for positive values this method uses floor()
and for negative values the method ceil() is used

The status bit int64overflow will be set, if value is out of range [LLONG_MIN..LLONG_MAX].
In case of value < LLONG_MIN the status bit negative will also be set.
Notice:
Also in case of int64overflow, intDbl always represents the mathematical correct integer value!!!
In other words: intDbl will not be limitted to an integer range.
int64overflow is a usefull information before casting value into a int64 variable.
Example:
double value = -DBL_MAX;
double intDbl = 0.0;
double intDblExpected = -DBL_MAX; //expected result
int64 intExpected = LLONG_MIN;
BM_STATUS bms;
bms.status = 0;
int64 result = doubleToInt64( value, &intDbl, &bms );
printBM_STATUS( bms, 0 );
printf("integer of %f is %ld (64 bit integer)", value, result );
printf("integer of %f is %f (64 bit double)", value, intDbl );
Output
status = 0x80001000 (negative int64overflow )
integer of -1.797693e+308 is -9223372036854775808 (64 bit integer)
integer of -1.797693e+308 is -1.797693e+308 (64 bit double)
int findDouble ( const double *  element1,
const unsigned int  count,
const double  elem 
)

looks for a same element in the array

and returns the zero based index into the array if an equal element is found

Parameters:
element1 pointer to the element in the array where to start
count number of relevant elements in the array beginning at element1
elem the element to be searched for
Returns:
the zero based index of the found element (up from element1).
Return of 0 means that element1[0] fits.
-1 if no element matched
-2 if element1 is a null pointer
int findI64 ( const __int64 *  element1,
const unsigned int  count,
const __int64  elem 
)

looks for a same element in the array

and returns the zero based index into the array if an equal element is found

Parameters:
element1 pointer to the element in the array where to start
count number of relevant elements in the array beginning at element1
elem the element to be searched for
Returns:
the zero based index of the found element (up from element1).
Return of 0 means that element1[0] fits.
-1 if no element matched
-2 if element1 is a null pointer
double floorDouble ( const double  value,
BM_STATUS bms 
)

Calculates the floor of value.

Calculates the largest integer that is less than or equal to value

Parameters:
value the value for this operation
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the integer value in double format
The result will be in range of [ -DBL_MAX .. +DBL_MAX ]
Hint:
This method uses the standard C function floor()
Examples:
double value = 2.1;
double result = floorDouble(value,0);
printf("\n floor of %f = %f", value, result);
value = -2.9;
result = floorDouble(value,0);
printf("\n floor of %f = %f", value, result);
Outputs:
floor of 2.1 = 2.0
floor of -2.9 = -3.0
int64 i64AddI64 ( const int64  augend,
const int64  addend,
BM_STATUS bms 
)

safe addition

adds addend to augend and returns the result of this operation

Parameters:
augend [in] the first value for this operation
addend [in] the second value for this operation
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of augend + addend (add)
int i64CompareI64 ( const int64  value1,
const int64  value2,
const int64  diff 
)

compares value1 with value2

Parameters:
value1 the first value to be compared with value2
value2 the second value to be compared with value1
diff difference to detect value1 != value2
Returns:
-1, if value1 is less than value2
0, if value1 is equal with value2
+1, if value1 is greater than value2
int64 i64DivI64 ( const int64  numerator,
const int64  denominator,
BM_STATUS bms 
)

safe division

divides numerator with denominator and returns the result of this operation

Parameters:
numerator [in] the first value for this operation
denominator [in] the second value for this operation
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of numerator / denominator (div)
int64 i64LogI64 ( const int64  base,
const int64  value,
BM_STATUS bms 
)

returns the base-logarithm of value

the log-function solves the equation
base pow result = value
and returns result in double format

Parameters:
base the base of the logarithm (useful >= 2)
value the logarithm's result
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the power to base so that base pow result = value
The result will be in range of [ -DBL_MAX .. +DBL_MAX ]
See also:
doubleRootDouble(), doubleRoot_2(),
doublePowDouble(), logDouble()
int64 i64ModI64 ( const int64  numerator,
const int64  denominator,
BM_STATUS bms 
)

safe modulo

divides numerator with denominator and returns the remainder as result of this operation

Parameters:
numerator [in] the first value for this operation
denominator [in] the second value for this operation
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of numerator % denominator (modulo)
Hint
if denominator is 0 (divide by zero), numerator will be returned and in bms the status bits divideZero and overflow will be set (no modulo active).
int64 i64MulI64 ( const int64  multiplier,
const int64  multiplicand,
BM_STATUS bms 
)

safe multiplication

multiplies multiplier with multiplicand and returns the result of this operation

Parameters:
multiplier [in] the first value for this operation
multiplicand [in] the second value for this operation
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of multiplier * multiplicand (mul)
int64 i64Pow_2 ( const int64  base,
BM_STATUS bms 
)

safe square (power 2)

calculates base raised to the power of 2 and returns the result of this operation

Parameters:
base [in] the base value for this operation
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of base ^ 2 (pow)
int64 i64Pow_3 ( const int64  base,
BM_STATUS bms 
)

safe cube (power 3)

calculates base raised to the power of 3 and returns the result of this operation

Parameters:
base [in] the base value for this operation
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of base ^ 3 (pow)
int64 i64Pow_4 ( const int64  base,
BM_STATUS bms 
)

safe power 4

calculates base raised to the power of 4 and returns the result of this operation

Parameters:
base [in] the base value for this operation
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of base ^ 4 (pow)
int64 i64PowI64 ( const int64  base,
const int64  exponent,
BM_STATUS bms 
)

safe power, calculates base pow exponent

calculates base raised to the power of exponent and returns the result of this operation

Parameters:
base [in] the base value for this operation
exponent [in] the exponent value for this operation
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of base ^ exponent (pow)
The result will be in range of [LLONG_MIN .. LLONG_MAX]
See also:
doubleRootDouble(), sqrtDouble(), logDouble()
int64 i64Root_2 ( const int64  radicand,
BM_STATUS bms 
)

safe square root

calculates the square root of radicand and returns the result of this operation

Parameters:
radicand [in] the value for this operation
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
if radicand >= 0 : sqrt( radicand )
if radicand < 0 : -sqrt( fabs( radicand ) ) and bms->negRadicand will be set
int64 i64RootI64 ( const int64  radicant,
const int64  rootExponent,
BM_STATUS bms 
)

safe exp-th root

calculates the exp-th root of radicant and returns the result of this operation

Parameters:
radicant [in] the value for this operation
rootExponent [in] the exponent of the root
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of root-exp( radicant )
int64 i64SubI64 ( const int64  minuend,
const int64  subtrahend,
BM_STATUS bms 
)

safe subtraction

subtracts subtrahend from minuend and returns the result of this operation

Parameters:
minuend [in] the first value for this operation
subtrahend [in] the second value for this operation
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of minuend - subtrahend (sub)
double i64ToDouble ( const int64  value  ) 

converts from int64 to a value in double format

Parameters:
value [in] the value which will be converted from int64 to double
Returns:
value in double format (64 bit floating point)
double invertSignDouble ( const double  value,
BM_STATUS bms 
)

inverts the sign of value

result = -value

Parameters:
value [in] the value for this operation
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of this operation in double format
The result will be in range of [ -DBL_MAX .. +DBL_MAX ]
See also:
invertSignDouble(), positiveDouble(), negativeDouble()
int64 invertSignI64 ( const int64  value,
BM_STATUS bms 
)

inverts the sign of value

result = -value

Parameters:
value [in] the value for this operation
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of this operation in int64 format
The result will be in range of [ LLONG_MIN .. LLONG_MAX ]
If value is < -LLONG_MAX the result is LLONG_MAX and in bms the status bit int64overflow will be set.
See also:
invertSignDouble(), positiveDouble(), negativeDouble()
int isDouble ( const double *  value,
BM_STATUS bms 
)

tests for a valid 64 bit floating point value (double)

Parameters:
value a pointer to the double value to be tested
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
0 = false, value points not to a valid 64 bit floating point number
1 = true, value points to a valid 64 bit floating point number
in bms (if bms != 0) status bit undef will be set, if value is not valid otherwise bms remains unchanged
Hint:
denormalized values are allowed!
int isEvenI64 ( const int64  value  ) 

returns 1 if value is even (.. -4, -2, 0, +2, +4, ..)

Parameters:
value [in] the value to be checked
Returns:
0 = false : value is odd 1 = true : value is even
int isI64 ( const int64 value,
BM_STATUS bms 
)

tests for a valid 64 bit integer value (int64)

Parameters:
value a pointer to the value to be tested
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
0 = false, value points not to a valid 64 bit number
1 = true, value points to a valid 64 bit number
in bms (if bms != 0) status bit undef will be set, if value is not valid otherwise bms remains unchanged
Hint:
returns false if value is a null pointer
double negativeDouble ( const double  value,
BM_STATUS bms 
)

calculates the negative absolute value of value

result = -fabs( value )

Parameters:
value [in] the value for this operation
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of this operation in double format
The result will be in range of [ -DBL_MAX .. 0 ]
See also:
invertSignDouble(), positiveDouble(), negativeDouble()
int64 negativeI64 ( const int64  value  ) 

calculates the negative absolute value of value

result = -abs( value )

Parameters:
value [in] the value for this operation
Returns:
the result of this operation in int64 format
The result will be in range of [ LLONG_MIN .. 0 ]
See also:
invertSignDouble(), positiveDouble(), negativeDouble()
double positiveDouble ( const double  value,
BM_STATUS bms 
)

calculates the absolute value of value

result = fabs( value )

Parameters:
value [in] the value for this operation
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of this operation in double format
The result will be in range of [ 0 .. +DBL_MAX ]
See also:
invertSignDouble(), positiveDouble(), negativeDouble()
int64 positiveI64 ( const int64  value,
BM_STATUS bms 
)

calculates the absolute value of value

result = abs( value )

Parameters:
value [in] the value for this operation
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of this operation in int64 format
The result will be in range of [ 0 .. LLONG_MAX ]
If value is < -LLONG_MAX the result is LLONG_MAX and in bms the status bit int64overflow will be set.
See also:
invertSignDouble(), positiveDouble(), negativeDouble()
void printBM_STATUS ( const BM_STATUS  bms,
FILE *  file 
)

prints a basic math status (BM_STATUS) to file

Parameters:
bms basic math status to be printed
file pointer to a open FILE with write access.
If file=0 (default) this function prints to stdout.
If file is a valid pointer this function prints to file.
Example:
BM_STATUS bms;
bms.status = 0;
doubleDivDouble( 123.456, 0.0, &bms );
printBM_STATUS( bms, (FILE*)0 );
Result:
status = 0x4 (divideZero )
Comment:
The status text in brackets is sorted from hi-bit (left alligned) to lo-bit
If status is null, the printed text has no brackets. It is only "status = 0x0"
If there are more then 1 bit set, the output looks like "status = 0x82 (negative overflow)"
The status text is the same as the name of the status bit. E.g. if the bit 'undef' is set the status text will be "undef"
void printDoubleBitpattern ( double  value,
FILE *  file 
)

prints the bitpattern of a double value in hex format

Parameters:
value the value to be printed
file pointer to a open FILE with write access.
If file=0 (default) this function prints to stdout.
If file is a valid pointer this function prints to file.
Example:
double myFloat = 123.456;
printDoubleBitpattern( myFloat, (FILE*)0 );
Result:
405edd2f1a9fbe77
Illustration:

4 0 5 e d d 2 f 1 a 9 f b e 7 7
Bit 63..0
0100 0000 0101 1110 1101 1101 0010 1111 0001 1010 1001 1111 1011 1110 0111 0111
Bit 51..0: normalized significand
Bit 62..52: exponent
Bit 63: sign
See also:
printDoubleBitpatternFormated()
void printDoubleBitpatternFormatted ( double  value,
FILE *  file 
)

prints the formatted bitpattern of a double value (sign mantisse exponent)

Parameters:
value the value to be printed
file pointer to a open FILE with write access.
If file=0 (default) this function prints to stdout.
If file is a valid pointer this function prints to file.
Example:
double myFloat = 123.456;
printDoubleBitpatternFormatted( myFloat );
Result:
sign=0 significant=edd2f1a9fbe77 exponent=405
Hint:
All printed values are in hex-format.
See also:
printDoubleBitpattern()
double rad2DegDouble ( const double  radian,
BM_STATUS bms 
)

converts radian into degree

degree = (rad / pi) * 180

Parameters:
radian [in] the radian value
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the degree value
double reciprocDouble ( const double  value,
BM_STATUS bms 
)

safe reciproc (1/x)

returns the result of 1 / x

Parameters:
value [in] the value for this operation
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of 1 / value
double roundDouble ( const double  value,
const int  decPlaces,
BM_STATUS bms 
)

rounds value to a specified number of decimal places

decPlaces can be negative

Parameters:
value [in] the value to be rounded
decPlaces [in] Positive number indicates how many places to the right of the decimal are included in the rounding.
If omitted (decPlaces=0), assignRound() rounds to integer.
Negative number indicates how many places to the left of the decimal are included in the rounding.
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of this operation in double format
The result will be in range of [ -DBL_MAX .. +DBL_MAX ]
Hint:
For negative values this formula will be used to calculate the rounded value:
result = ( value * 10^decPlaces - 0.5 ) / 10^decPlaces
For positive values this formula will be used to calculate the rounded value:
result = ( value * 10^decPlaces + 0.5 ) / 10^decPlaces
double sinDouble ( const double  rad,
BM_STATUS bms 
)

calculates the sinus of rad

result = sin( rad )

Parameters:
rad the angle [-DBL_MAX .. +DBL_MAX]
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of this operation in double format
The result will be in range of [-1 .. +1]
Hint:
the parameter rad will be interpreted in rad (circular measure).
See also:
sinDouble(), cosDouble(), tanDouble(), cotDouble()
asinDouble(), acosDouble(), atanDouble(), acotDouble()
rad2DegDouble(), deg2RadDouble()
void sortAscendantDouble ( double *  values,
const unsigned long  count,
BM_STATUS bms 
)

sorts an array of values in ascendant order

Parameters:
values [in,out] the values to be sorted
returns the sorted values in the same array
count [in] number of values in values
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the ascendat sorted values in the same array
void sortAscendantI64 ( int64 values,
const unsigned long  count 
)

sorts an array of values in ascendant order

Parameters:
values [in,out] the values to be sorted
returns the sorted values in the same array
count [in] number of values in values
Returns:
the ascendat sorted values in the same array
double stringToDouble ( const char *  stringValue,
BM_STATUS bms 
)

converts stringValue into double

Parameters:
stringValue pointer to the first character in the string where the value begins
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the 64 bit floating point value
Hint:
This method uses strtod() to convert the string into a 64 bit float value.
If the string converting failed with errno = ERANGE (overflow),
the status bits strErr and overflow will be set bms.
In case of a negative overflow the status bit negative will also be set.
If there are no valid characters in the string
the status bits strErr and undef will be set in bms.
int64 stringToI64 ( const char *  stringValue,
char **  stopChar,
BM_STATUS bms 
)

converts stringValue into int64

Parameters:
stringValue pointer to the first character in the string where the value begins
stopChar [out,opt] (can be null) pointer into stringValue where the scanner stopped
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the 64 bit integer value
Hint:
If the string converting failed because of overflow
the status bits strErr and/or overflow will be set in bms.
In case of a negative overflow the status bit negative will also be set.
If there are no valid characters in the string
the status bits strErr and undef will be set in bms.
double strToDouble ( const char *  str,
BM_STATUS bms 
)

converts a null terminated string into a 80 bit floating point value (double)

returns the value represented by the string

Parameters:
str [in] the zero terminated string
fpvalue ::= {whitespace}[sign]value[echar[sign]integer]
whitespace ::= ' ' | '\t' | '\n' | '\r' //blank or tabulator or linefeed or carriage return
sign ::= '+' | '-' //plus or minus
seperator ::= ',' | '_' //comma or underline
digit ::= '0' ... '9' //a value in the range 0..9
integer ::= digit {digit} //integer has at least one digit
int_sep ::= digit {[seperator]digit} //integer begins and ends always
//with a digit, not with a seperator
value ::= (integer) | (integer'.') | (integer'.'integer) | ('.'integer)
echar ::= 'd' | 'D' | 'e' | 'E' //one of these characters indicates the
//power to base 10
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the value represented by the string
double tanDouble ( const double  rad,
BM_STATUS bms 
)

calculates the tangent of rad

result = tan( rad )

Parameters:
rad the angle [-DBL_MAX .. +DBL_MAX]
bms [out,opt] A pointer to receive basic math status informations (can be null).
bms remains unchanged if there is no error in this operation.
bms acts accumulative.
Returns:
the result of this operation in double format
The result will be in range of [ -DBL_MAX .. +DBL_MAX ]
Hint:
value will be interpreted in rad (circular measure).
value must be in range of [ -DBL_MAX .. +DBL_MAX ]
except the values [k*PI/2 (for k element N and k != 0)]

With 64 bits, pi/2 is not so exact that tan( pi/2 ) will overflow.
In other words: Don't worry about the poles within the tan-function.
See also:
sinDouble(), cosDouble(), tanDouble(), cotDouble()
asinDouble(), acosDouble(), atanDouble(), acotDouble()
rad2DegDouble(), deg2RadDouble()
 All Classes Files Functions Variables Typedefs Defines
Generated on Mon Nov 22 06:27:34 2010 by  doxygen 1.6.3