ProLinga-Calc Project

The ProLinga-Calc Project is a small project which focusses on the development of a library which, after implementing, enables any application to make C expression type calculations. Simple expressions as x=2+3 and more complicated ones like x=2*sin(y).

Main purpose for the creation of this project, is to provide an easy way to perform calculations from the ProLinga 4GL programming language. Since the result library of this project is very open, simple and easy to implement, it can be used in other non-ProLinga related projects.

Input for the ProLinga-Calc library are normal C expressions containing operators, float or integer constants, variables and references to previous results ($n). Precedence and semantic of operators is the same as in C language. There are two extra binary operators: >>> unsigned shift right and ** raising to power. ProLinga-Calc supports the standard set of functions from C mathematics library and also defines function prime(n), which returns smallest prime number >= n.

Operators:

  • ++ -- ! ~ unary + -

  • **

  • * / %

  • + -

  • << >> >>>

  • < <= > >=

  • == !=

  • &

  • ^

  • |

  • = += -= *= /= %= <<= >>= >>>= &= |= ^= **=

Functions:

  • abs

  • acos

  • asin

  • atan

  • atan2

  • cos

  • cosh

  • exp

  • int

  • float

  • log

  • log10

  • prime

  • sin

  • sinh

  • sqrt

  • tan

  • tanh

To test the library, a small binary called prolingacalc is built when compiling.

Figure 1. Screenshot prolingacalc binary

Screenshot of the prolingacalc binary.

ProLinga-Calc has been built and tested on several popular GNU/Linux platforms as RedHat Fedora, Mandriva Linux, Debian, openSUSE Linux, Ubuntu and MS-Windows (Cygwin). Since all code is written in C++, it can be ported to all modern UNIX systems, Linux variants as well as Windows and Mac O/S platforms.

Portions of code are lifted from the freeware application ccalc V1.01 programmed by Konstantin Knizhnik.