Christophe Delord ~ cdsoft.fr

Calculadoira

A programmer's Calculator using Bonaluna

Recherche d'emploi : ingénieur en informatique

Christophe Delord est actuellement en CDI mais à la recherche d'un nouvel emploi.

Type de poste:poste à dominante R&D en informatique, architecture
Compétences:aéronautique, DO 178B, logiciel embarqué, simulation, vérification, certification, outillage, automatisation, ... (CV : HTML ou PDF )
Localisation:région toulousaine ou télétravail (déplacements possibles)
Contact:Christophe Delord
Author:Christophe Delord
Web site:http://www.cdsoft.fr/calculadoira
Date:Sunday 19 May 2013
License:This software is released under the GPL license.
Download:

Table of Contents

1   Introduction

Calculadoira is inspired by Calc.

Calculadoira is based on Bonaluna instead of Python. It's lighter and faster to load.

+---------------------------------------------------------------------+
|     C A L C U L A D O I R A     | v. 2.1.9 | cdsoft.fr/calculadoira |
|---------------------------------------------------------------------|
| Modes:                          | Numbers:                          |
|     hex oct bin float ieee str  |     binary: b... or ...b          |
|---------------------------------|     octal : o... or ...o          |
| Variable and function:          |     hexa  : h... or ...h or 0x... |
|     variable = expression       |     float : 1.2e-3                |
|     function(x, y) = expression | Chars     : "abcd" or 'abcd'      |
| Multiple statements:            |             "<abcd" or ">abcd"    |
|     expr1, ..., exprn           | Booleans  : true or false         |
|---------------------------------|-----------------------------------|
| Builtin functions:              | Operators:                        |
|     see help                    |     or xor and not                |
|---------------------------------|     < <= > >= == !=               |
| Commands: ? help license bye    |     cond?expr:expr                |
|           edit ascii            |     + - * / % ** | ^ & >> << ~    |
+---------------------------------------------------------------------+

2   Command line usage

Calculadoira accepts command line parameters:

filename
loads a file and evaluates its content. This may be used to import some user libraries before entering an interactive session.

calculadoira.ini is automatically loaded if it exists.

The edit command edits the first loaded file. Changes are automatically reloaded, it's not necessary to restart Calculadoira.

3   Help

: help

Constants                   Value
=========================== ===============================================

inf                         +oo
nan                         Not a Number
pi                          3.1415926535898
e                           2.718281828459

Operators / functions       Description
=========================== ===============================================

+x, -x
x + y, x - y                sum, difference
x * y, x / y, x % y         product, division, modulo
x ** y                      x to the power y

~x                          bitwise not
x | y, x ^ y, x & y         bitwise or, xor, and
x << n, x >> n              x left or right shifted by n bits

not x                       boolean not
x or y, x xor y, x and y    boolean or, xor, and
x < y, x <= y               comparisons
x > y, x >= y
x == y, x != y, x ~= y

x!                          the factorial of x
|x|                         the absolute value of x

abs(x)                      the absolute value of x
ceil(x)                     the smallest integer larger than or equal to x
floor(x)                    the largest integer smaller than or equal to x
mantissa(x)                 m such that x = m2e, |m| is in [0.5, 1[
exponent(x)                 e such that x = m2e, e is an integer
int(x)                      the integral part of x
fract(x)                    the fractional part of x
fmod(x, y)                  the remainder of the division of x by y
ldexp(m, e)                 m*2**e (e should be an integer)
pow(x, y)                   x to the power y
min(...), max(...)          the minimum / maximum value among its arguments

sqr(x)                      the square of x (x**2)
sqrt(x)                     the square root of x (x**0.5)

cos(x), acos(x), cosh(x)    trigonometric functions
sin(x), asin(x), sinh(x)
tan(x), atan(x), tanh(x)
atan2(y, x)                 the arc tangent of y/x (in radians)
deg(x)                      the angle x (given in radians) in degrees
rad(x)                      the angle x (given in degrees) in radians

exp(x)                      e**x
log(x), ln(x)               logarithm of x in base e
log10(x), log2(x)           logarithm of x in base 10, 2
log(x, b)                   logarithm of x in base b

random()                    random number in [0, 1[
random(m)                   random integer in [1, m]
random(m, n)                random integer in [m, n]
randomseed(x)               x as the "seed" for the pseudo-random generator

float2ieee(x)               the IEEE 754 representation of x
ieee2float(n)               the float value of the IEEE 754 integer value n

Display modes
=============

hex, oct and bin commands change the display mode.
When enabled, the integer result is displayed in
hexadecimal, octal and/or binary.
float mode shows the float value of a 32 bit IEEE float.
ieee mode shows the IEEE coding of a 32 bit float.
str mode show the ASCII representation of 1 to 4 chars.

Blocks
======

A block is made of several expressions separated by `,` or ` `.
The value of the block is the value of the last expression.

e.g. x=1, y=2, x+y defines x=1, y=2 and returns 3

Definitions made in functions are local.

e.g. f(x) = (y=1, x+y) defines a function f that
returns x+1. y is local to f.

Local definitions can be functions.

e.g. fact(n) = (f(n,p)=(n==1)?p:f(n-1,n*p), f(n,1))

Operator precedence
===================

From highest to lowest precedence:

Operator family             Syntax
=========================== =================
Precedence overloading      (...)
Absolute value              |x|
Function evaluation         f(...)
Factorial                   x!
Exponentiation              x**y
Unary operators             +x, -y, ~z
Multiplicative operators    * / % & << >>
Additive operators          + - | ^
Relational operators        < <= > >= == !=
Logical not                 not x
Logical and                 and
Logical or                  or xor
Ternary operator            x ? y : z
Assignement                 x = y
Blocks                      expr1, ..., exprn

Other commands
==============

bye                         quit
edit                        edit the configuration file
ascii                       print an ASCII table

Credits
=======

Calculadoira: http://www.cdsoft.fr/calculadoira
BonaLuna    : http://www.cdsoft.fr/bl

"Calculadoira" means "Calculator" in Occitan.


: license

Calculadoira
Copyright (C) 2011 - 2012 Christophe Delord
http://www.cdsoft.fr/calculadoira

Calculadoira is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Calculadoira is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Calculadoira.  If not, see <http://www.gnu.org/licenses/>.

4   Examples

4.1   Functions

: reverse(x) = (d=int(x/10), u=x%10, u*10+d)


: answer = reverse(24)

=       42

: fact(n) = n>1 ? n*fact(n-1) : 1


: fact(answer)

=       1.4050061177529e+51

: answer * 1000

=       42000

4.2   ASCII codes

: '42'

=       13362
hex     0000 3432
str     "42"

: lower(ascii) = ascii | ' ', lower('A')

=       97
hex     0000 0061
bin     0000 0000 0000 0000 0000 0000 0110 0001
str     "a"

: upper(ascii) = ascii & ~' ', upper('a')

=       65
hex     0000 0041
bin     0000 0000 0000 0000 0000 0000 0100 0001
str     "A"

4.3   IEEE floats

: ieee


: 1.5

=       1.5
ieee    0x3FC00000

: ieee


: float


: 0x3fc00000 | 1<<31

=       3217031168
hex     BFC0 0000
bin     1011 1111 1100 0000 0000 0000 0000 0000
float   -1.5

5   Operating Systems support

5.1   GNU/Linux

Calculadoira is intended to run in a terminal. It works everywhere Bonaluna (i.e. Lua) runs.

Just execute calculadoira.lua (bl shall be in the PATH).

5.2   Windows

Calculadoria license for Windows users

Calculadoira is free (as in freedom) but Windows users have to unlock Calculadoira to remove the license notice and to support Calculadoira development.

To register and receive a key file, just donate using either Flattr or PayPal (see below) and send your registration name by email at Christophe Delord.

Prices are:

  • 10 € for a single user individual license
  • 20 € for a single user professional license
  • 190 € for a 10 user professional license
  • 1800 € for a 100 user professional license

But Linux users can support Calculadoira too ;-)

Calculadoira also has a standalone executable for Windows. calculadoira.exe contains calculadoira.lua, the default configuration file and a Bonaluna interpretor.

Support

If you find these softwares useful, you are free to donate something to support their future evolutions. Thanks for your support.

You can use Flattr or PayPal to support these softwares.

Flattr PayPal