Skip to main content

Module math

Module math 

Source
Expand description

Mathematical expression evaluation for zshrs

Direct port from zsh/Src/math.c

Supports:

  • Integer and floating point arithmetic
  • All C operators (+, -, *, /, %, <<, >>, &, |, ^, etc.)
  • Zsh ** power operator
  • Comparison operators (<, >, <=, >=, ==, !=)
  • Logical operators (&&, ||, !)
  • Ternary operator (? :)
  • Assignment operators (=, +=, -=, *=, /=, etc.)
  • Pre/post increment/decrement (++, –)
  • Base conversion (16#FF, 2#1010, [16]FF)
  • Special values (Inf, NaN)
  • Variable references and assignment

Structs§

MathEval
Math evaluator state

Enums§

MathNum
Math number - can be integer or float

Functions§

matheval
Convenience function to evaluate a math expression
mathevalf
Evaluate and return float
mathevali
Evaluate and return integer