Read Me
Features
==----==
Post Processing Filters
Comments
Variables
Error Reporting
Base Conversion
Constants
Operational Modes
Parenthesial Support
Using Ub3rMath
==----------==
1- Use the included makefile to build the library. You will need cygwin or something similar to build on windows
2- Link your project against libUb3rMath.a and include libUb3rMath.h
4- Use the Ub3rMath class
Supported Operators
==---------------==
==- Basic Operators -==
+ Addition (a + b)
- Substraction (a - b)
/ Division (a / b)
* Multiplication (a * b)
^ Exponentiation (a ^ b)
% Modulus (a % b)
! Factorial (a !)
sqrt Square Root (sqrt a)
rt Nth Root (a rt b)
log 10th Logarithm (log a)
elog Natural Log (elog a)
round Round (round a)
floor Round Down (floor a)
ceil Round Up (ceil a)
==- Geometric Operators -==
tan Tangeant (tan a)
cos Cosine (cos a)
sin Sine (sin a)
atan Inverse Tan (atan a)
acos Inverse Cos (acos a)
asin Inverse Sin (asin a)
cotan Cotangeant (cotan a)
sec Secant (sec a)
cosec Cosecant (cosec a)
Post Processing Filters
==-------------------==
Filters can be added at the beginning of an equation followed by '<'
Example: hex<16 (The output would be 0xf)
The following filters are supported:
bin binary output (ex: 0b111)
hex hexadecimal output (ex: 0bfff)
oct octal output (ex: 0o777)
cel2far temperature to farenheit
far2cel temperature to celcius
Variables
==-----==
Appending 'x=' to the beginning of an equation (after post processing filters), where x is any alphanumeric character besides 'e' allows you to use variables in subsequent equations.
Example:
x=5+5 (Outputs 10)
10x (Outputs 100)
Error Reporting
==-----------==
The following errors are defined, get them with LastError() or LastErrorMessage():
EQUATION_VALID 0x00
No error, use to validate equations
UNKNOWN_FILTER 0x01
A filter was called that does not exist
INVALID_LEFT_SIDE 0x02
The left side of the equation (x=) was invalid
INVALID_NUMBER 0x03
A number was not formatted correctly
INVALID_DOT_COUNT 0x04
An integer contained too many dots
UNKNOWN_VARIABLE 0x05
A variable used in the equation was not set
INVALID_EQUATION 0x06
An illegal character was used in the equation, or symbols were used improperly
OPERATOR_INCORRECT 0x07
An operator was not used properly, or one or more of it's operands were missing
PARENTHESES_INCORRECT 0x08
Parentheses were not used properly
INVALID_ANSWER 0x09
The answer was invalid
Base Conversion
==-----------==
Numbers of any base can be used easily:
0x-- Hexadecimal
0d-- Decimal
0o-- Octal
0b-- Binary
Where -- is a valid number in the specified format
Constants
==-----==
Some constants are defined and can be called by name:
e 2.718281828459045235360287471352
pi 3.141592653589793238462643383279
Operational Modes
==-------------==
Using the SetFlags(int flags) method, any combination onf the following can be used:
MODE_RADIANS 0x0000
Use radians in calculations
MODE_DEGREES 0x1000
Use degrees in calculations
MODE_LEFTREM 0x0000
Do not append the left side of the equation to the output (ex: x=)
MODE_LEFTAPP 0x0100
Append the left side of the equation to the output (ex: x=)
MODE_FIXED
Output everything in fixed point notation
MODE_FLOAT
Output everything in floating point notation
MODE_SCI
Output everything in scientific notation
The default mode is:
MODE_RADIANS | MODE_LEFTREM | MODE_FLOAT
Parenthesial Support
==----------------==
Parentheses can be used in equations to override operator priority
Example:
5/5+5 (Outputs 5)
5/(5+5) (Outputs 0.5)