The KCalc Handbook

The KCalc Handbook

The KCalc Handbook

Bernd Johannes Wuebben

Pamela Roberts

Reviewer: Lauri Watts

Revision 1.03.01

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".

KCalc is a scientific calculator for KDE


Chapter 1. Introduction

Introduction

Chapter 1. Introduction

This document describes KCalc version 1.3.1.

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 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.

Have fun with KCalc!

Bernd Johannes Wuebben

KDE Logo
Chapter 2. Usage

Usage

Chapter 2. 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 left mouse button 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 Up and Down arrow 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 the left mouse button on KCalc's display will place the displayed number on to the clipboard.

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

Statistical and Trigonometric Modes

KCalc can run in Statistical or Trigonometric mode. Pressing F3 will toggle between the modes or you can set the mode with the Configuration dialog brought up by pressing the Configure button or with F2.

Statistical Mode

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

ButtonsFunction
NRecall the number of data items entered
InvNDisplay the sum of all data items entered
MeaDisplay the mean of the data items entered
InvMeaDisplay the sum of the square of all data items entered
StdDisplay the standard deviation (n)
InvStdDisplay the population standard deviation (n-1)
MedDisplay the median
DatEnter a data item
InvDatClear last data item entered
CstClear the store of all data item entered
Trigonometric Mode

Trigonometric Mode

Trigonometric Mode

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

ButtonsFunction
HypEnter Hyperbolic sub mode. Hyp Sin for example is the hyperbolic sine: sinh(x)
SinCompute the sine
InvSinCompute the inverse sine
CosCompute the cosine
InvCosCompute the inverse cosine
TanCompute the tangent
InvTanCompute the inverse tangent
LogCompute the Log base 10
InvLogCompute 10 to the power of x
LnCompute the natural logarithm. That is the log to base e
InvLnCompute e to the power of x
KDE Logo
Single Key Accelerators

Single Key Accelerators

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).

KeyFunctionNotes
HHypHyperbolic as in Hyp Sin, the sinh(x)
SSin 
CCos 
TTan 
NLnlog base e
LLoglog base 10
IInvInverse, e.g. if you want arcsin(x) type i s
\+/-Change sign
[x^2 
^x^y 
!x!Factorial
<LshLeft shift. Note: InvLsh is Right shift
&AndLogical AND
*XMultiply
//Divide
DDatEnter data item in statistical mode
OOrLogical OR. Note: InvOr is XOR
R1/xReciprocal
== 
Enter= 
Return= 
Page UpCClear
EscCClear
PriorCClear
Page DownACClear all
NextACClear all
DelACClear all
F1?Help, brings up this manual
F2ConfigureBring up the configure dialog
F3 Switch between Trigonometric and Statistical modes
KDE Logo
KDE Logo
Chapter 3. Comments on Specific Functions

Comments on Specific Functions

Chapter 3. 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 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 - show the result as a percentage of the final 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.

  • 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 % key gives identical results to the = key.

Examples:

11 + 89 % gives 112.35.. (89 + 11 = 100, and 100 is 112.35 percent of 89)

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

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

2 ^ 300 % gives 8 (2 to the power (300/100))

KDE Logo
Lsh and Inv Lsh

Lsh and Inv Lsh

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.

KDE Logo
Cmp, And, Or and Inv Or

Cmp, And, Or and Inv Or

Cmp, And, Or and Inv Or

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

Inv Or performs the logical XOR (exclusive OR) operation.

101 Inv Or 110 = gives 11

KDE Logo
KDE Logo
Chapter 4. Questions and Answers

Questions and Answers

Chapter 4. Questions and Answers

4.1. How do I get pi=3.1415926...?
4.2. How do I get e, the Euler number?
4.3. How do I get two fixed digits after the period?
4.4. What about Precision?
4.1.

How do I get pi=3.1415926...?

Simply type Inv EE.

4.2.

How do I get e, the Euler number?

Type 1 Inv Ln.

4.3.

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.

4.4.

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.

KDE Logo
Chapter 5. Credits and License

Credits and License

Chapter 5. Credits and License

KCalc Program copyright 1996-1998 Bernd Johannes Wuebben <wuebben@kde.org>.

Additions by Espen Sand. <espen@kde.org>, 2000

Additions by Evan Teran. <amt3734@rit.edu>, 2001

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

Documentation copyright 2001,2002:

This documentation is licensed under the terms of the GNU Free Documentation License.

This program is licensed under the terms of the GNU General Public License.

KDE Logo
Appendix A. Installation

Installation

Appendix A. 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

KCalc is part of the KDE project http://www.kde.org/.

KCalc can be found in the kdeutils package on ftp://ftp.kde.org/pub/kde/, the main FTP site of the KDE project.

In order to compile and install KCalc on your system, type the following in the base directory of the KCalc distribution:

% ./configure
% make
% make install

Since KCalc uses autoconf and automake you should have no trouble compiling it. Should you run into problems please report them to the KDE mailing lists.

How to enable long double precision for KCalc

How to enable long double precision for KCalc

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.

Here is what to do:

Procedure A.1.

  1. Check ../config.h and see whether HAVE_LONG_DOUBLE is defined, i.e. 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 files kcalctype.h, configdlg.cpp, kcalc.cpp and kcalc_core.cpp and remove the lines:

    #ifdef HAVE_LONG_DOUBLE
    #undef HAVE_LONG_DOUBLE
    #endif
    
  3. Recompile KCalc.

KDE Logo
KDE Logo
KDE Logo