michael105 / calcit

A tiny calculator for the terminal. Featuring binary ops and branches. Tested on OSX x64 and Linux 32bit. 8k on osx x64, linked statical with minilib. Only whole numbers(!), no fractions.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

#calcit (calc)



Part of an expression parser and calculator.

This is a standalone version.

Currently I'm about to rewrite some things,
the ongoing work is in calc2.c

Originally I did want to implement the option of having
arithmetic expressions in config files, and to parse and compile them.
(For things like: if the mouse movement is faster than x/second, 
speed up with 2*x..)

Didn't write the config parser yet.

The recursive calculation has been a special pain in the ass.

It's tiny - 8k at OSX, compiled statically with minilib (optional)


6.3k linked statically with minilib, linux x64.


Working: (calc)
+ - * / 
% ^ $  	  ( Modulo, Power,  unsigned power-  ipowerui)
& | ! ~ X (Binary ops: ~ is bitwise not,  X is XOR)
L R 		  Shift left / right
< >       evals left side / right side, gives smaller / bigger value
=				  1, if equal


All operations are in integer mode, so no floating point yet.
Originally I did want to have some sort of scripting available for config files.



------


So, now there's also 'hal300'...
Not finished yet. 
But at least able to spit out the results in decimal, hex, oct and binary.

There might be the possibility to store functions.
I forgot the syntax.

calc.c, and calc2.c/libcalc.c do have different approaches.

Both are recursive, but while calc.c uses a case statement,
the latter ones do have jumptables.

The current version of linenoise didn't work, some trouble
with the columns.

Here's a fixed one.

BSD License.


misc 2013-2023
misc23 at posteo dot net
subtract 16 from 23

About

A tiny calculator for the terminal. Featuring binary ops and branches. Tested on OSX x64 and Linux 32bit. 8k on osx x64, linked statical with minilib. Only whole numbers(!), no fractions.

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:C 98.6%Language:Makefile 1.4%