1
0
Fork
You've already forked lcalc
0
forked from lch361/lcalc
A command line calculator. Simple and efficient, suitable for medium-sized calculations and scripts.
  • Zig 100%
2025年02月13日 14:57:08 +03:00
demo Moved demos to their own folder 2025年02月11日 19:40:57 +03:00
doc Fixed some typos in a readme 2025年02月12日 08:07:52 +03:00
man Implemented user-defined functions. 2025年02月11日 03:09:02 +03:00
src Updated pop() usage for newer master versions 2025年02月13日 14:57:08 +03:00
.gitignore Removed old build system 2024年10月16日 01:13:43 +03:00
build.zig Noticed and fixed some version format bugs 2025年02月07日 02:51:35 +03:00
examples.md Moved demos to their own folder 2025年02月11日 19:40:57 +03:00
LICENSE Implemented full documentation inside of a program. 2025年01月25日 14:23:35 +03:00
README.md Implemented full documentation inside of a program. 2025年01月25日 14:23:35 +03:00

lcalc

A command–Line Calculator.

Features

  • GUI–free calculation of mathematical expressions.
  • Integer (4), rational (7/3), floating (2.3) and complex (2 + 3i) numbers.
  • Binary, (+, *, /, ...), unary (-, ...) operators.
  • Variables: x = 5.
  • Predefined constants: pi or π, e, and more.
  • Predefined functions: max(1, 2), sin(pi), ....
  • User–defined functions: csc(x) = 1/sin(x)
  • Intuitive syntax, close to a math notation, but unambiguous: 3x (2sin(z) / 4y)
  • Numbers in different bases: hex (0xFF), bin (0b10110), oct (0o777).
  • Modern, but simple interface with syntax highlighting and themes.
  • Documentation inside of a command–line: help, for specific operations — help +.

See examples for a visual showcase.

Downloading

The releases page has archives of a precompiled executable for different operating systems. These also include the documentation.

Every archive is signed via minisign with the following public key:

RWTW/iadZl5EZQtwd5E0HKfXXzjq6ePMGtKhz5VAPm7VLJHz19URs69p

Running

Once you've downloaded a desired archive, unpack it and run the file bin/lcalc inside.

Here is an example for Linux systems, let ./lcalc-1.0.0-x86_64-linux-gnu.tar.xz be the downloaded archive:

mkdir lcalc
cd lcalc
tar -xf ../lcalc-1.0.0-x86_64-linux-gnu.tar.xz
bin/lcalc

If the program fails to launch, check if you have GMP, MPFR, MPC libraries installed.

The executable can be used as standalone, but it won't be able to find its documentation if placed outside of the unpacked archive.

Installing

If you have an FHS–compliant system (in other words, Linux), you can install it to the standard prefix for the programs.

An example script to be run as root:

cd /usr/local
tar -xf ~/lcalc-1.0.0-x86_64-linux-gnu.tar.xz

Now, if the /usr/local/bin directory is in your PATH, you can enjoy running lcalc with all features and documentation.

Building from source

This project is written in Zig, with latest compiler version in mind: 0.14.0-dev.2557+f06ca14cb.

git clone https://codeberg.org/lch361/lcalc
cd lcalc
zig build -Doptimize=ReleaseFast # Or ReleaseSmall for different optimization
cd zig-out
bin/lcalc

To install to a different prefix, for example, /usr/local:

zig build --prefix /usr/local

To generate and install the man pages, you'll need Pandoc:

zig build man

Author

Made by me, lch361. See more about me and my projects at https://lch361.net.

License

This is a free software released under the GNU General Public License 3.0. Copy of this license is available in this repository as LICENSE.txt file, and gets shipped with every release archive.

This software is provided as is, with no warranty.