Difference between revisions of "Mathematical Functions"
From Flowcode Help
Jump to navigationJump to search(5 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | |||
:''See [[Calculation Icon Properties]]'' | :''See [[Calculation Icon Properties]]'' | ||
Line 51: | Line 50: | ||
|- | |- | ||
| align="center" | int = random() | | align="center" | int = random() | ||
− | | Generates a random number | + | | Generates a random number 0x0000 <=> 0xFFFF |
|- | |- | ||
| align="center" | fabs( x ), floor( x ), ceil( x ) | | align="center" | fabs( x ), floor( x ), ceil( x ) | ||
Line 69: | Line 68: | ||
|- | |- | ||
| align="center" | sin( x ), cos( x ), tan( x ) | | align="center" | sin( x ), cos( x ), tan( x ) | ||
− | | Trigonometric functions | + | | Trigonometric functions where x is in radians |
|- | |- | ||
| align="center" | asin( x ), acos( x ), atan( x ) | | align="center" | asin( x ), acos( x ), atan( x ) | ||
− | | Inverse trigonometric functions | + | | Inverse trigonometric functions where x is in radians |
|- | |- | ||
| align="center" | atan2( y , x ) | | align="center" | atan2( y , x ) | ||
Line 95: | Line 94: | ||
| Factorial | | Factorial | ||
|- | |- | ||
− | | align="center" | | + | | align="center" | SetPinNoDDR( PortPin, Output ) |
− | | | + | | Set output pin quickly without changing data direction state. |
+ | |- | ||
+ | | align="center" | Input = GetPinNoDDR( PortPin ) | ||
+ | | Read input pin quickly without changing data direction state. | ||
|} | |} |
Latest revision as of 10:50, 7 August 2023
The following mathematical functions can be used in calculations. All of these functions are now usable on each chip type.
Functions
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 0x0000 <=> 0xFFFF |
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 where x is in radians |
asin( x ), acos( x ), atan( x ) | Inverse trigonometric functions where x is in radians |
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 |
round( x ) | Decimal rounding (x rounded to the nearest integer) |
fround( x , y ) | Floating point rounding (x rounded to y decimal places) |
asinh( x ), acosh( x ), atanh( x ) | Inverse hyperbolic functions |
fact( x ) | Factorial |
SetPinNoDDR( PortPin, Output ) | Set output pin quickly without changing data direction state. |
Input = GetPinNoDDR( PortPin ) | Read input pin quickly without changing data direction state. |