• Utility corner
KCalc — a Lua-based expression evaluator and math library
Version 8.0, March 2013
Please note that this is a work in progress. Not all the functionality
of the previous version has yet been ported to version 8. The function
library is not stable, and new functions are being added.
What is this?
KCalc is an expression evaluator and math library based on the
Lua programming language. It is implemented partly in Lua and partly
in C. KCalc is designed to occupy a place between simple
pocket calculator-type applications, and heavyweights like Octave and
Matlab. Like the heavyweights it has full support for complex numbers,
and is extensible with scripts (in this case, using the Lua language).
Unlike them, it
consumes less than a megayte of storage and neglibible RAM, and
starts up very quickly even on low-powered platforms.
KCalc is a console (command-line) application, and should run on
any platform that can provide a C compiler and a prompt. Versions
are available for Linux, Cygwin, the native Windows prompt ('DOS box'),
and for Android (using a terminal emulator). It provides line editing
and history support via the GNU Ireadline library, on platforms
that support it (Cygwin and most unix-like environments do; the Windows
console does not).
To use KCalc as a calculator requires no knowledge of Lua
programming — it is completely self-contained. However, to add
new functionality does require at least a rudimentary understanding of
KCalc is supplied with a modest function library, providing support
for basic trigonometry, equation solving, statistical, financial, and
Building and installation
There is no automated installer for any platform except KBOX (Android).
of copying the executable
Windows) to some convenient directory,
creating a subdirectory
scripts in the same directory, and
copying the contents of the
scripts directory in the
source bundle to that subdirectory. KCalc works out the location
scripts directory from the location of its own
For convenience, binary bundles are provided for Windows (DOSBox
and Cygwin), and Fedora 14 Linux. The Cygwin and Linux bundles can be
unpacked (with administrator rights)
at the root level of the filesystem; no further setup is required.
Windows bundle is simply an archive that can be unpacked in any convenient
place. Run the program by invoking
the Windows Explorer, or create a shortcut to it.
On Unix/Linux systems other than Fedora 14, it will probably be
necessary to build
and install from source — I don't have time to provide binaries for all the different
versions around. In most cases cases, this ought to be no more complicated
that unpacking the source bundle, and running
$ make build
# make install
Please read the installation instructions before downloading.
Source code bundle for all platforms
Binary bundle for Cygwin
Binary bundle for Fedora 14
Binary bundle for Windows DOSBox
Installer package for KBox (Android)
See the page for the KBOX project here for an
details of the KBOX project for Android devices.
Author and legal
KCalc is maintained by Kevin Boone, and distributed under the terms
of the GNU Public Licence, v2.0. Essentially, this meams that you may
use this software as you wish, at your own risk, provided that the
original author continues to be acknowledged.
Please report bug, etc., using the details on the
KCalc man page
Lua 5.2 reference manual