~yerinalexey/csq

Simple fraction calculator

2edf0c5 Implement unary minus

12 days ago

d73545c Use tuple unpacking where possible

a month ago

#csq

csq - calculator squared, or just calculator²

Fancy command-line calculator that uses fractions instead of decimal floating point numbers.

It works like any other calculator, with exception of division, which returns a fraction. After evaluation, the result is reduced, so 21 / 7 = 3/1 = 3. Basic line editing is also provided. Press Ctrl+D to quit.

Syntax reference:

  • a + b, a - b, a * b, a / b - self-explanatory
  • a ^ b - raises a to the power of b, b must have denominator of 1
  • a % b - returns the remainder from divsion of a by b, both must have denominator of 1
  • (expression) - sets highest precedence for expression
  • $N - returns the value of N-th expression
  • sqrt a - returns a very approximated square root of a
  • mixed 1|0 - enables or disables mixed fraction display

Example:

$ csq
(1) 21 / 7 = 3
(2) 7 / 21 = 1/3
(3) $2 * 3 = 1
(4) sqrt 64 = 8

#Installation

At build time, a recent Hare toolchain is required.

$ make
# make install

#Contributing

Please send patches to ~yerinalexey/public-inbox@lists.sr.ht using git send-email with prefix set to csq:

$ git config format.subjectPrefix "PATCH csq"