Difference between revisions of "Mathematical Functions"

From Flowcode Help
Jump to navigationJump to search
Line 6: Line 6:
 
Flowcode includes an additional set of mathematical functions:
 
Flowcode includes an additional set of mathematical functions:
  
 
+
{| class="wikitable"
float = fadd(float, float) - Add two floating point numbers together
+
|-
 
+
! scope="col"| Function Prototype
float = fsub(float, float) - Subtract two floating point numbers
+
! scope="col"| Description
 
+
|-
float = fmul(float, float) - Multiply two floating point numbers
+
| float = fadd(float, float)
 
+
| Add two floating point numbers together
float = fdiv(float, float) - Divide two floating point numbers
+
|-
 
+
| float = fsub(float, float)
float = fmod(float, float) - MOD function for floating point numbers
+
| Subtract two floating point numbers
 
+
|-
byte = isinf(float) - Checks to see if the floating point number is infinite
+
| float = fmul(float, float)
 
+
| Multiply two floating point numbers
byte = isnan(float) - Checks to see if the floating point is not a number
+
|-
 
+
| float = fdiv(float, float)
byte = float_eq(float, float) - Compares two floating point numbers to see if they are equal
+
| Divide two floating point numbers
 
+
|-
byte = float_ge(float, float) - Compares two floating point numbers to see if they are greater then or equal
+
| float = fmod(float, float)
 
+
| MOD function for floating point numbers
byte = float_gt(float, float) - Compares two floating point numbers to see if they are greater then
+
|-
 
+
| byte = isinf(float)
byte = float_le(float, float) - Compares two floating point numbers to see if they are less then or equal
+
| Checks to see if the floating point number is infinite
 
+
|-
byte = float_lt(float, float) - Compares two floating point numbers to see if they are less then
+
| byte = isnan(float)
 
+
| Checks to see if the floating point is not a number
int = random()   - Generates a random number -32768 <=> 32767
+
|-
 
+
| byte = float_eq(float, float)
 
+
| Compares two floating point numbers to see if they are equal
 
+
|-
Functions (Flowcode AVR only)
+
| byte = float_ge(float, float)
 
+
| Compares two floating point numbers to see if they are greater then or equal
Flowcode includes an additional set of mathematical functions:
+
|-
 
+
| byte = float_gt(float, float)
 
+
| Compares two floating point numbers to see if they are greater then
fabs( x ), floor( x ), ceil( x ) - absolute value, floor and ceiling functions
+
|-
 
+
| byte = float_le(float, float)
fmod( x , y )                         - floating point modulus (remainder of x divided by y)
+
| Compares two floating point numbers to see if they are less then or equal
 
+
|-
sqrt( x ), cbrt( x )                 - square and cube roots
+
| byte = float_lt(float, float)
 
+
| Compares two floating point numbers to see if they are less then
log( x ), log10( x )                 - logarithms (base e and base 10)
+
|-
 
+
| int = random()
exp( x ), pow( x , y )               - exponential and power functions (x to the power of y)
+
| Generates a random number -32768 <=> 32767
 
+
|-
sin( x ), cos( x ), tan( x )       - trigonometric functions
+
| fabs( x ), floor( x ), ceil( x )
 
+
| absolute value, floor and ceiling functions
asin( x ), acos( x ), atan( x ),      - inverse trigonometric functions             
+
|-
 
+
| fmod( x , y )
atan2( y , x )                       - four-quadrant inverse tangent
+
| floating point modulus (remainder of x divided by y)
 
+
|-
sinh( x ), cosh( x ), tanh( x )       - hyperbolic functions
+
| sqrt( x ), cbrt( x )
 
+
| square and cube roots
isnan( x ), isinf( x )               - tests for not-a-number and infinity
+
|-
 
+
| log( x ), log10( x )
 
+
| logarithms (base e and base 10)
 
+
|-
Functions (Flowcode ARM only)
+
| exp( x ), pow( x , y )
 
+
|exponential and power functions (x to the power of y)
Flowcode includes an additional set of mathematical functions:
+
|-
 
+
| sin( x ), cos( x ), tan( x )
 
+
| trigonometric functions
fabs( x ), floor( x ), ceil( x ) - absolute value, floor and ceiling functions
+
|-
 
+
| asin( x ), acos( x ), atan( x )
round( x )                         - decimal rounding (x rounded to the nearest integer)
+
| inverse trigonometric functions             
 
+
|-
fround( x , y )                       - floating point rounding (x rounded to y decimal places)
+
| atan2( y , x )
 
+
| four-quadrant inverse tangent
fmod( x , y )                         - floating point modulus (remainder of x divided by y)
+
|-
 
+
| sinh( x ), cosh( x ), tanh( x )
sqrt( x ), cbrt( x )                 - square and cube roots
+
| hyperbolic functions
 
+
|-
log( x ), log10( x )                 - logarithms (base e and base 10)
+
| isnan( x ), isinf( x )
 
+
| tests for not-a-number and infinity
exp( x ), pow( x , y )               - exponential and power functions (x to the power of y)
+
|-
 
+
| fabs( x ), floor( x ), ceil( x )
sin( x ), cos( x ), tan( x )       - trigonometric functions
+
| absolute value, floor and ceiling functions
 
+
|-
asin( x ), acos( x ), atan( x ),       - inverse trigonometric functions             
+
| round( x )
 
+
| decimal rounding (x rounded to the nearest integer)
atan2( y , x )                       - four-quadrant inverse tangent
+
|-
 
+
| fround( x , y )
sinh( x ), cosh( x ), tanh( x )       - hyperbolic functions
+
| floating point rounding (x rounded to y decimal places)
 
+
|-
asinh( x ), acosh( x ), atanh( x )   - inverse hyperbolic functions
+
| fmod( x , y )
 
+
| floating point modulus (remainder of x divided by y)
fact( x )                             - factorial
+
|-
 
+
| sqrt( x ), cbrt( x )
random( )                             - random number between 0 and 32767
+
| square and cube roots
 
+
|-
isnan( x ), isinf( x )               - tests for not-a-number and infinity
+
| log( x ), log10( x )
 +
| logarithms (base e and base 10)
 +
|-
 +
| exp( x ), pow( x , y )
 +
| exponential and power functions (x to the power of y)
 +
|-
 +
| sin( x ), cos( x ), tan( x )
 +
| trigonometric functions
 +
|-
 +
| asin( x ), acos( x ), atan( x ),
 +
| inverse trigonometric functions             
 +
|-
 +
| atan2( y , x )
 +
| four-quadrant inverse tangent
 +
|-
 +
| sinh( x ), cosh( x ), tanh( x )
 +
| hyperbolic functions
 +
|-
 +
| asinh( x ), acosh( x ), atanh( x )
 +
| inverse hyperbolic functions
 +
|-
 +
| fact( x )
 +
| factorial
 +
|-
 +
| random( )
 +
| random number between 0 and 32767
 +
|-
 +
| isnan( x ), isinf( x )
 +
| tests for not-a-number and infinity
 +
|}

Revision as of 15:01, 17 May 2013

The following mathematical functions can be used in calculations. Some are limited to different chip types.


Functions (Flowcode PIC only)

Flowcode includes an additional set of mathematical functions:

Function Prototype Description
float = fadd(float, float) Add two floating point numbers together
float = fsub(float, float) Subtract two floating point numbers
float = fmul(float, float) Multiply two floating point numbers
float = fdiv(float, float) Divide two floating point numbers
float = fmod(float, float) MOD function for floating point numbers
byte = isinf(float) Checks to see if the floating point number is infinite
byte = isnan(float) Checks to see if the floating point is not a number
byte = float_eq(float, float) Compares two floating point numbers to see if they are equal
byte = float_ge(float, float) Compares two floating point numbers to see if they are greater then or equal
byte = float_gt(float, float) Compares two floating point numbers to see if they are greater then
byte = float_le(float, float) Compares two floating point numbers to see if they are less then or equal
byte = float_lt(float, float) Compares two floating point numbers to see if they are less then
int = random() Generates a random number -32768 <=> 32767
fabs( x ), floor( x ), ceil( x ) absolute value, floor and ceiling functions
fmod( x , y ) floating point modulus (remainder of x divided by y)
sqrt( x ), cbrt( x ) square and cube roots
log( x ), log10( x ) logarithms (base e and base 10)
exp( x ), pow( x , y ) exponential and power functions (x to the power of y)
sin( x ), cos( x ), tan( x ) trigonometric functions
asin( x ), acos( x ), atan( x ) inverse trigonometric functions
atan2( y , x ) four-quadrant inverse tangent
sinh( x ), cosh( x ), tanh( x ) hyperbolic functions
isnan( x ), isinf( x ) tests for not-a-number and infinity
fabs( x ), floor( x ), ceil( x ) absolute value, floor and ceiling functions
round( x ) decimal rounding (x rounded to the nearest integer)
fround( x , y ) floating point rounding (x rounded to y decimal places)
fmod( x , y ) floating point modulus (remainder of x divided by y)
sqrt( x ), cbrt( x ) square and cube roots
log( x ), log10( x ) logarithms (base e and base 10)
exp( x ), pow( x , y ) exponential and power functions (x to the power of y)
sin( x ), cos( x ), tan( x ) trigonometric functions
asin( x ), acos( x ), atan( x ), inverse trigonometric functions
atan2( y , x ) four-quadrant inverse tangent
sinh( x ), cosh( x ), tanh( x ) hyperbolic functions
asinh( x ), acosh( x ), atanh( x ) inverse hyperbolic functions
fact( x ) factorial
random( ) random number between 0 and 32767
isnan( x ), isinf( x ) tests for not-a-number and infinity