# The &kcalc; Handbook

&Bernd.Johannes.Wuebben; &Bernd.Johannes.Wuebben.mail;
&Pamela.Roberts;&Pamela.Roberts.mail;
2001 2002 2005 &Bernd.Johannes.Wuebben;, &Pamela.Roberts;
&FDLNotice;
2005-04-12
1.8

&kcalc; is a scientific calculator for &kde;

KDE KCalc calculator

## Introduction

This document describes &kcalc; version 1.8.

&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; provides trigonometric functions, logic operations, and it is able to do statistical calculations.

- &kcalc; allows you to cut and paste numbers from/into its display.

- &kcalc; features a results-stack which lets 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.

  Hint: Pressing (and holding) the &Ctrl;-key, displays on every button, the corresponding key-binding.

Have fun with &kcalc;!

Bernd Johannes Wuebben

## Usage

### General Usage

General usage is straight forward and similar to the way most simple scientific calculators operate, but take note of the following special &kcalc; features:

Result Stack

  Each time you &LMB; click on the = button or press your keyboard's Enter or = keys, the display result is written to &kcalc;'s result stack. You can navigate through the result stack with your keyboard's &Ctrl;Z and &Ctrl; &Shift;Z keys.

Percent Function

  The percent function works somewhat differently to that on most calculators. However, once understood, its enhanced functionality proves quite useful. See the section about the percent function for further details.

Cut and Paste

  - Pressing &Ctrl;C will place the displayed number on to the clipboard.

  - Pressing &Ctrl;V will paste the clipboard content into the display if the content of the clipboard is a valid floating point number.

  - It is still possible to copy/paste by clicking on &kcalc;'s display, but this may disappear in future versions.

Advanced functions

  When you start &kcalc; for the first time, the calculator will only display buttons for basic arithmetic computations.

  Under the menu entry Settings it is possible to open extra buttons for &kcalc;: It is for example possible to choose Statistical or Trigonometric buttons.

### Statistical Mode

In this mode the left column of buttons is allocated to statistical functions:

Most of the functionality in this mode is centered around the Dat button. To create a data list of numbers, enter a number into the calculator and press Dat. A sequentially increasing number is shown on the display indicating which position in the Data list the number occupies. A traditional calculator only stores three values for statistical functions: The number of discrete items in a list, the sum of the data items entered and the sum of the square of all data items in the list. &kcalc; differs by actually storing each discrete value, allowing you to calculate the median value of the data.

Buttons | Function
--- | ---
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 the store of all data item entered

### Trigonometric Mode

In this mode the left column of buttons is allocated to trigonometric functions:

Buttons | Function
--- | ---
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 tangent
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 to base e
Inv Ln | Compute e to the power of x

### Memory Operations

&kcalc; supports the memory operations given by standard calculators plus six slots to hold constants.

#### Standard Memory Operations

&kcalc; can remember results of operations for you, and re-use them in later calculations. You can access these functions via several buttons labelled MR, MS, M+ and MC.

MS

  The MS button stores the currently displayed result in memory.

M+

  The M+ adds the current result to the one in memory. So, if you had stored a 20, and the current result is a 5, your memory would contain 25 when you press it. If the memory is empty, it acts like MS and simply stores the result.

MR

  The MR button gets the value stored in memory and puts it in the display.

MC

  The MC button clears the memory.

If a value is stored in memory a M will appear in the status bar, next to the calculator mode indicator

#### Constants

The six constants buttons C1 to C6 will only be visible after activating the item Constants Buttons in the menu Settings of the menu bar.

To store the number shown in the &kcalc;-display on one of the six constants buttons, press first Inv followed by the desired button key C1 up to C6.

To use the value stored in any of the contants buttons in a calculation, just press the desired button C1 - C6, and the corresponding number will appear in the display.

It is possible to change the label of the constants button to make it easier for the user to remember which button holds which constant. Klick with the right mouse button on one of C1 - C6. A popup menu appears, where one has to select Set Name.

There are many (mostly physical) predefined constants, which can be put on any of the six buttons C1 - C6 by selecting the desired constant in the popup menu that appears after right clicking on one of the constant buttons and selecting Choose from List. Though the predefined constants can also be accessed via the Constants in the menu bar, storing it on a constants button is very handy, if the number is used frequently.

### Single Key Accelerators

To simplify entering calculations from the keyboard &kcalc; has single key accelerators for most functions. For example entering `7R` or `7r` will calculate the reciprocal of 7 (1/7).

During a computation, you can always press &Ctrl; to make each button display its key-binding.

Key | Function | Notes
--- | --- | ---
H | Hyp | Hyperbolic as in Hyp Sin, the sinh(x)
S | Sin |
C | Cos |
T | Tan |
N | Ln | log base e
L | Log | log base 10
I | Inv | Inverse, ⪚ if you want arcsin(x) type `i s`
\ | +/- | Change sign
[ | x^2 |
^ | x^y |
! | x! | Factorial
< | Lsh | Left shift. Note: Inv Lsh is Right shift
& | And | Logical AND
* | X | Multiply
/ | / | Divide
D | Dat | Enter data item in statistical mode
O | Or | Logical OR. Note: Inv Or is XOR
R | 1/x | Reciprocal
= | = |
Enter | = |
Return | = |
Page Up | C | Clear
Esc | C | Clear
Prior | C | Clear
Page Down | AC | Clear all
Next | AC | Clear all
Del | AC | Clear all

## Comments on Specific Functions

### Mod and Inv Mod

Mod gives the remainder of dividing the displayed number by the next input number.

  `22 Mod 8 =` will give the result 6

  `22.345 Mod 8 =` will give the result 6.345

Inv Mod does integer division of the displayed number by the next input number.

  `22 Inv Mod 8 =` will give the result 2

  `22.345 Inv Mod 8 =` also gives 2

### %

Used instead of the = key, % interprets the final operation carried out in the current calculation as follows:

- If the final operator is + or - the second argument is interpreted as percentage of the first operand.

- If the final operator is * divide the result of the multiplication by 100.

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

- In all other cases the % key gives identical results to the = key.

Examples:

  `150 + 50 %` gives 225 (150 plus 50 percent of this amount)

  `42 * 3 %` gives 1.26 (42 * 3 / 100)

  `45 / 55 %` gives 81.81... (45 is 81.81.. percent of 55)

### Lsh and Inv Lsh

Lsh left shifts the integer part of the displayed value (multiplies it by 2) n times, where n is the next input number, and gives an integer result:

  `10 Lsh 3 =` gives 80 (10 multiplied by 2 three times).

  `10.345 Lsh 3 =` also gives 80.

Inv Lsh right shifts the value (performs an integer divide by 2) n times.

  `16 Inv Lsh 2 =` gives 4 (16 divided by 2 twice).

  `16.999 Inv Lsh 2 =` also gives 4.

### Cmp, And, Or and Xor

The Cmp, And and Or functions perform bitwise logical operations and therefore appear more meaningful if the Base is set to Hex, Oct or Bin rather than Dec. In the following examples Base is set to Bin.

Cmp performs a 1's complement (inverts the bits).

  `101 Cmp` gives 111...111010

And does a logical AND.

  `101 And 110 =` gives 100

Or does the logical OR.

  `101 Or 110 =` gives 111

Xor performs the logical XOR (exclusive OR) operation.

  `101 Xor 110 =` gives 11

## Questions and Answers

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 Configure button, this will bring up the configuration dialog. Check 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 the Configure dialog box) 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 calculator provided with &Windows;.

Adjust the Precision in &kcalc;'s Configure dialog so that the above computations work correctly. I recommend a precision of 14 if the fundamental data type for your copy of &kcalc; is long double, otherwise 8 or 10.

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

## Credits and License

&kcalc; Program Copyright ©:

Bernd Johannes Wuebben 1996-2000

The &kde; Team 2000-2004

- &Bernd.Johannes.Wuebben; &Bernd.Johannes.Wuebben.mail;

- &Evan.Teran; &Evan.Teran.mail;

- &Espen.Sand; &Espen.Sand.mail;

- &Chris.Howells; &Chris.Howells.mail;

- &Aaron.J.Seigo; &Aaron.J.Seigo.mail;

- &Charles.Samuels; &Charles.Samuels.mail;

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

Documentation Copyright © 2001,2002,2005:

- &Bernd.Johannes.Wuebben; &Bernd.Johannes.Wuebben.mail;

- &Pamela.Roberts; &Pamela.Roberts.mail;

- &J.Hall;&J.Hall.mail;

&underFDL; &underGPL;

## Installation

&kcalc; is part of the kdeutils package within the &kde; project and will normally be provided as part of a &kde; installation. For more details about &kde; visit http://www.kde.org.

### Compilation and Installation

&install.intro.documentation; &install.compile.documentation;

### 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 precision for &kcalc;.

Here is what to do:

- Check `../config.h` and see whether HAVE_LONG_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.

- Edit the files `kcalctype.h`, `configdlg.cpp`, `kcalc.cpp` and `kcalc_core.cpp` and remove the lines:

      #ifdef HAVE_LONG_DOUBLE
      #undef HAVE_LONG_DOUBLE
      #endif

- Recompile &kcalc;.