Mathematical Expressions and Functions
Radix Quest evaluates mathematical expressions through a custom JavaScript parser. The parser tokenizes expressions, converts them to Reverse Polish Notation using a shunting-yard algorithm, and evaluates the resulting operations. It does not use JavaScript eval() to execute the expression.
Arithmetic Operators
| Operator | Operation | Example |
|---|---|---|
+ | Addition | 5+3 |
- | Subtraction | 9-4 |
* | Multiplication | 6*7 |
/ | Division | 20/4 |
% | Remainder | 10%3 |
^ | Exponentiation | 2^8 |
** | Exponentiation | 2**8 |
- | Unary negation | -5 |
+ | Unary positive | +5 |
Use * for multiplication and / for division.
Operator Precedence
Radix Quest evaluates expressions according to its parser's precedence rules.
From highest to lowest:
- Unary positive, unary negative, and bitwise NOT
- Exponentiation
- Multiplication, division, and remainder
- Addition and subtraction
- Bit shifts
- Bitwise AND
- Bitwise XOR
- Bitwise OR
Exponentiation is right-associative.
Example
2^3^2Result:
512This is interpreted as:
2^(3^2)Parentheses
Use parentheses to control evaluation order.
(2+3)*4Result:
20Mathematical Functions
The following functions are available in floating-point mode.
| Function | Description | Example |
|---|---|---|
sin(x) | Sine | sin(pi/2) |
cos(x) | Cosine | cos(0) |
tan(x) | Tangent | tan(pi/4) |
asin(x) | Inverse sine | asin(0.5) |
acos(x) | Inverse cosine | acos(0) |
atan(x) | Inverse tangent | atan(1) |
sqrt(x) | Square root | sqrt(81) |
log(x) | Base-10 logarithm | log(1000) |
ln(x) | Natural logarithm | ln(e) |
abs(x) | Absolute value | abs(-12) |
floor(x) | Round downward | floor(3.9) |
ceil(x) | Round upward | ceil(3.1) |
round(x) | Round to nearest integer | round(3.6) |
min(...) | Minimum value | min(4,8,2) |
max(...) | Maximum value | max(4,8,2) |
Trigonometric Angles
Trigonometric functions use radians.
Examples:
sin(pi/2)
cos(pi)
tan(pi/4)To convert degrees to radians within an expression:
sin(30*pi/180)Inverse trigonometric functions also return radians.
Mathematical Constants
| Constant | Meaning |
|---|---|
pi | π |
tau | 2π |
e | Euler's number |
Examples:
2*pi*5e^2Constants are available in floating-point mode, not integer mode.
Numeric Literals
Radix Quest supports:
- Decimal integers
- Decimal fractions
- Scientific notation
- Prefixed binary integers
- Prefixed octal integers
- Prefixed hexadecimal integers
Examples:
123
3.14159
1.5e3
0b1010
0o17
0xFFUnderscores can be used as separators in integer literals.
1_000_000Floating-Point Precision
Floating-point calculations use JavaScript Number arithmetic.
This follows IEEE 754 double-precision behavior.
For example:
0.1+0.2may produce:
0.30000000000000004This is normal floating-point behavior.
For fixed-width integer operations, use Integer / Bitwise mode.
Domain Errors
Operations such as:
sqrt(-1)or:
log(-10)cannot produce finite real-number results.
Radix Quest reports an error rather than returning a valid complex-number result.
Complex arithmetic is not implemented.
Important Limitations
- Implicit multiplication is not supported; use
2*pi, not2pi. - The calculator does not support variables or user-defined functions.
- Floating-point precision is limited by JavaScript Number.
- Integer-mode functions differ from floating-point functions.
- The parser does not implement symbolic algebra.
- Expressions must follow the supported operator and function syntax.
Note: Unary negation has higher precedence than exponentiation in this parser. Use explicit parentheses when evaluating negative powers to avoid ambiguity.
Updated 7 days ago
