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

OperatorOperationExample
+Addition5+3
-Subtraction9-4
*Multiplication6*7
/Division20/4
%Remainder10%3
^Exponentiation2^8
**Exponentiation2**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:

  1. Unary positive, unary negative, and bitwise NOT
  2. Exponentiation
  3. Multiplication, division, and remainder
  4. Addition and subtraction
  5. Bit shifts
  6. Bitwise AND
  7. Bitwise XOR
  8. Bitwise OR

Exponentiation is right-associative.

Example

2^3^2

Result:

512

This is interpreted as:

2^(3^2)

Parentheses

Use parentheses to control evaluation order.

(2+3)*4

Result:

20

Mathematical Functions

The following functions are available in floating-point mode.

FunctionDescriptionExample
sin(x)Sinesin(pi/2)
cos(x)Cosinecos(0)
tan(x)Tangenttan(pi/4)
asin(x)Inverse sineasin(0.5)
acos(x)Inverse cosineacos(0)
atan(x)Inverse tangentatan(1)
sqrt(x)Square rootsqrt(81)
log(x)Base-10 logarithmlog(1000)
ln(x)Natural logarithmln(e)
abs(x)Absolute valueabs(-12)
floor(x)Round downwardfloor(3.9)
ceil(x)Round upwardceil(3.1)
round(x)Round to nearest integerround(3.6)
min(...)Minimum valuemin(4,8,2)
max(...)Maximum valuemax(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

ConstantMeaning
piπ
tau2π
eEuler's number

Examples:

2*pi*5
e^2

Constants 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
0xFF

Underscores can be used as separators in integer literals.

1_000_000

Floating-Point Precision

Floating-point calculations use JavaScript Number arithmetic.

This follows IEEE 754 double-precision behavior.

For example:

0.1+0.2

may produce:

0.30000000000000004

This 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, not 2pi.
  • 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.


Did this page help you?