Crates.io | rzcalc |
lib.rs | rzcalc |
version | 0.1.0 |
source | src |
created_at | 2024-02-09 12:13:18.59956 |
updated_at | 2024-02-09 12:13:18.59956 |
description | Simple calculator expression parser and evaluater using recursive descent parser, written in rust |
homepage | https://github.com/RizalAchp/rzcalc |
repository | https://github.com/RizalAchp/rzcalc |
max_upload_size | |
id | 1133876 |
size | 34,502 |
Simple calculator written in Rust. Supports many arithmetic functions, boolean logic, and builtin functions.
The calculator supports four value types:
true
and false
)1
, 3.2
, -200
, 1.3333
, 1e-3
, 0xFFFFF
, 0b010011
, 0o777
)
Supports the following operations:
a + b
a - b
a * b
a / b
a % b
a & b
a | b
a ^ b
a >> b
a << b
a == b
, a != b
a < b
, a <= b
, a > b
, a >= b
Conjunction: a and b
Disjunction: a or b
Negation: not a
[] Supports the following constants.
pi
tau
e
nan
inf
neginf
[] The following common mathematical functions are supported.
sin(x)
, cos(x)
, tan(x)
asin(x)
, acos(x)
, atan(x)
ln(x)
, log10(x)
, log2(x)
, log(x, base)
round(x)
, floor(x)
, ceil(x)
sqrt(x)
, exp(x)
, powf(x, e)
, pow(x, e)
abs(x)
, min_num(x, y)
, max_num(x, y)
[] The following Python-like utility functions are included.
min(...)
: minimum of arguments.max(...)
: maximum of arguments.rand()
, rand(stop)
, rand(start, stop)
: random float (default range is 0.0 to 1.0).[] The following common printing functions to stdout/stderr are supported.
print(value)
: print to stdoutprintln(value)
: print to stdout with new line at the endeprint(value)
: print to stderreprintln(value)
: print to stderr with new line at the enddebug(expr)
: print debug representation for expression[] The following common format number functions.
bin(value, _bool)
: format number as string in binary format (0b111
)oct(value, _bool)
: format number as string in octal format (0o777
)hex(value, _bool)
: format number as string in hex format (0xFFF
)