# The KCalc Handbook

Bernd Johannes
Wuebben

    wuebben@kde.org

Version 0.4, 20 September 1997

This Handbook describes KCalc Version 0.4

The KCalc Handbook

KDE
KCalc
calculator

## Introduction

This is release 0.4 of KCalc. KCalc is a simple but hopefully useful scientific calculator for the KDE project.

KCalc offers many more mathematical functions than meet the eye on a first glance. Please study the section on keyboard accelerators and modes in this handbook to learn more about the many functions available.

In addition to the usual functionality offered by most scientific calculators, KCalc offers a number of features, which I think are worthwhile pointing out:

- KCalc has a trigonometric and a statistics mode.

- KCalc allows you to cut and paste numbers from/into its display.

- KCalc features a 'results-stack' which let's you conveniently recall previous results.

- You can configure KCalc's display colors and font.

- You can configure KCalc's precision and the number of digits after the period.

- KCalc offers a great number of useful key-bindings, which make using KCalc without using a pointing device easy.

Have fun with KCalc!

`Bernd Johannes Wuebben`

wuebben@math.cornell.edu

## Installation

### How to obtain KCalc

KCalc is part of the KDE project http://www.kde.org. KCalc can be found on ftp://ftp.kde.org/pub/kde/, the main ftp site of the KDE project. It's home site is http://math.cornell.edu/~wuebben/kde.html

### Requirements

In order to successfully compile KCalc, you need the latest versions of `libkdecore` and `libkdeui`. All required libraries as well as KCalc itself can be found on ftp://ftp.kde.org/pub/kde/.

### Compilation and installation

The usual:

    % ./configure
    % make
    % make install

IMPORTANT:

How to enable long double precision for KCalc:

If your machine supports the C data type 'long double' and if you have a working libc you can enable 'long double' precison for KCalc.

( RedHat 5.0 users are out of luck -- I suggest you get yourself a KDE friendly Linux distribution that has a working libc )

Here is what to do:

1. Check ../config.h and see whether HAVE&lowbar;LONG&lowbar;DOUBLE is defined, ie you should be able to locate a line saying:

       #define HAVE_LONG_DOUBLE 1

   If you can't find such a line your system doesn't support long double IEEE precision.

2. Edit the file kcalctype.h configdlg.cpp kcalc.cpp and kcalc&lowbar;core.cpp and remove the lines

       #ifdef HAVE_LONG_DOUBLE
       #undef HAVE_LONG_DOUBLE
       #endif

3. recompile KCalc.

## Usage

General usage is straight forward and similar if not identical to the way most simple scientific calculators operate. Click on the KCalc button to bring up the configuration dialog.

### Result Stack

Each time you click the enter button or press the 'equal' or 'Enter' or 'Return' keys, the display result is written to KCalc's result stack. You can navigate through the result stack by pressing the up and down arrow keys.

### Percent Function

The percent function works somewhat different from that of most calculators. However, once understood, its enhance functionality proves quite useful. See the section on the percent function in the "Comments on specific functions" section for a details explanation of the percent functionality.

### Fixed Precision

Click the fixed precision check-box on the configure dialog if you whish to fix the number of digits which are displayed past the period.

### Cut and Paste

- Pressing the left mouse button on KCalc's display will place the displayed number on to the clip-board.

- Pressing the right or middle mouse button on KCalc's display will paste the clip-board content into the display if the content of the clip-board is a valid floating point number.

## Modes

### Statistical Mode

Press F3 to toggle between statistical and trigonometry mode. Alternatively bring up the configuration dialog by pushing the KCALC button or by pressing F2 to switch into statistics mode.

N

  Recall the number of data items entered

INV N

  Display the sum of all data items entered

Mea

  Display the mean of the data items entered

INV Mea

  Display the sum of the square of all data items entered

Std

  Display the standard deviation (n)

INV Std

  Display the population standard deviation (n-1)

Med

  Display the median

Dat

  Enter a data item

INV Dat

  Clear last data item entered

Cst

  Clear all data item entered

### Trigonometric Mode

Press F3 to toggle between statistical and trigonometry mode. Alternatively bring up the configuration dialog by pushing the KCALC button or by pressing F2 to switch into trigonometric mode.

Hyp

  Enter Hyperbolic sub mode. HYP SIN for example is the hyperbolic sine: sinh(x)

Sin

  Compute the sine.

INV Sin

  Compute the inverse sine.

Cos

  Compute the cosine.

INV Cos

  Compute the inverse cosine.

Tan

  Compute the tangents.

INV Tan

  Compute the inverse tangent.

Log

  Compute the Log base 10

INV Log

  Compute 10 to the power of x.

Ln

  Compute the natural logarithm. That is the log with base e.

INV Ln

  Compute e to the power of x.

## Key Accels

(TODO): This list is probably incomplete. Check!

    F1         Help
    F2         Config Dialog
    F3         Switch into Trigonometry Mode
    F4         Switch into Statistics Mode

    Up Key     display previous element of the result stack
    Down Key   display next element of the result stack
    Page UP    Clear
    Prior      Clear
    Page Down  Clear All
    Next       Clear All

    ALT + d    set trig-mode to deg
    ALT + r    set trig-mode to rad
    ALT + g    set trig-mode to grad
    ALT + e    set radix to decimal
    ALT + o    set radix to octal
    ALT + b    set radix to binary

    s          Sin
    c          Cos
    t          Tan
    n          ln  = log base e
    l          log = log base 10
    i          Inv inverse, e.g. if you want arcsin(x) type i s
    \          +/-
    [          ^2
    ^          x^y
    =          =
    !          factorial
    <          left shift
    >          right shift
    &          AND
    *          multiply
    /          divide

    d          enter stat data item ( in stat mode)

    o          OR
    INV o      XOR
    r          1/x r for reciproc
    Enter      =
    Return     =
    Backspace  Clear All
    Del        Clear All
    Esc        Clear
    h          Hyp (Hyperbolic) as e.g in Hyp Sin , the sinh(x)

## Comments on specific functions

### Mod

Give the remainder of dividing the display number by the next input number.

### Inv Mod

Integer divison of the display number by the next input number.

### &percnt;

Interpret the final operation carried out in the current calculation as follows:

- The function of the &percnt; key is similar to the one found on some CASIO calculators:

- If the final operator is + give the percentage increase the result is over the second operand.

- If the final operator is - give the percentage decrease the result is over the second operand.

- If the final operator is * give the right operand as a percentage of the left operand.

- If the final operator is / or Mod, give the left operand as a percentage of the right operand.

- If the final operator is x**y give the left operand raised to the power of the (right operand / 100).

- In all other cases the &percnt; key gives identical results to the = key.

#### Examples

    Type:             45 / 55 %
    Answer Displayed: 81.8181...
    Explanation:      45 is 81.81...percent of 55

    Type:             11 + 89 %
    Answer Displayed: 112.35..
    Explanation:      89 + 11 = 100 and  100 is 112.35 percent of 89.

### Lsh (Rsh)

Left (right) shift the n times, where n is the next input number. You get Rsh (right shift) by pressing INV Lsh.

## Tips and Tricks

### Fonts

I found that several distributions don't know how to set the FontPath right and which fonts to install in order to get great fonts under X11. I can't help you gather great fonts for X11, but I can show you what my FontPath in /etc/XF86Config looks like -- this will help you getting better results for xemacs as well as kcalc:

    Section "Files"
       RgbPath    "/usr/X11R6/lib/X11/rgb"
       FontPath   "/usr/X11R6/lib/X11/fonts/misc:unscaled"
       FontPath   "/usr/X11R6/lib/X11/fonts/75dpi:unscaled"
       FontPath   "/usr/X11R6/lib/X11/fonts/100dpi:unscaled"
       FontPath   "/usr/X11R6/lib/X11/fonts/Type1"
       FontPath   "/usr/X11R6/lib/X11/fonts/Speedo"
       FontPath   "/usr/X11R6/lib/X11/fonts/misc"
       FontPath   "/usr/X11R6/lib/X11/fonts/75dpi"
       FontPath   "/usr/X11R6/lib/X11/fonts/100dpi"
       FontPath   "/usr/X11R6/lib/X11/fonts/cyrillic"
    EndSection

## Questions and Answers

### How do I get pi=3.1415926...?

Simply type INV EE.

### How do I get e, the Euler number?

Type 1 INV ln.

### How do I get two fixed digits after the period?

Click on the KCalc button, this will bring up the configuration dialog. Click on "Set Fixed Precision" and adjust the spin control so that it shows a 2.

### What about Precision?

The main factor determining the precision of kcalc is whether your libc and libmath supports the C data type `long double`. If this is the case, kcalc will detect this at compile time and use it as its fundamental data type to represent numbers. Check KCalc's about dialog in order to find out what the fundamental data type for your copy of KCalc is.

Unless you have a libc and libmath of exceptionally high quality, you will be able to observe some "interesting" results when trying to execute computations such as: 123.22 - 123.21; 2.01 - 2; 123.88 - 123.87 and similar. However if you think this is bad I ask you to do the same computation on the windows calculator.

Adjust the precision on KCalc's configure dialog so that the above computation go through correctly. I recommend a precision of 14 if the fundamental data type for your copy of KCalc is long double, otherwise 8 or 10.

Note: Higher precision doesn't necessarily lead to better results. Play with the precision and you will see what I mean.

## Copyright

    KCalc Copyright 1996,1997 Bernd Johannes Wuebben
                              wuebben@math.cornell.edu

    KCalc was inspired by Martin Bartlett's xfrmcalc, whose stack
    engine is still part of KCalc.

    This program 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 2 of the License, or
    (at your option) any later version.

    This program 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 this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.