ONLINE CALCULATOR

- Evaluate mathematical expressions in various numerical systems -

MANUAL:
1. Introduction
2. Basic Operators
    2.1 Addition & Subtraction
    2.2 Multiplication & Division
    2.3 Modulo
    2.4 Exponentiation
    2.5 Binary Left/Right Shift
    2.6 AND, OR, XOR & NOT Operators
    2.7 Operator Precedence
 3. Functions
    3.1 Square Root (sqrt)
    3.2 Sinus (sin)
    3.3 Cosinus (cos)
    3.4 Tangent (tan)
    3.5 Natural Logarithm (log)
    3.6 Base 10 Logarithm (log10)
    3.7 Arcus Sinus (asin)
    3.8 Arcus Cosinus (acos)
    3.9 Arcus Tangent (atan)
    3.10 Hyperbolic Sinus (sinh)
    3.11 Hyperbolic Cosinus (cosh)
    3.12 Hyperbolic Tangent (tanh)
    3.13 Converting Radians to Degress (todeg)
    3.14 Converting Degress to Radians (torad)
    3.15 Round (round)
    3.16 Floor (floor)
 4. Constants
 5. Numerical Systems
    5.1 Specify a number in a different base
    5.2 Specify the result in a different base
 6. About / Info
    6.1 History

Show/Hide Manual

1. Introduction

This applet allows you to evaluate mathematical expressions and convert numbers to various numerical bases. Note that all numbers are treated as floating points numbers (doubles). The syntax and operators are very similar to C and Java - some small derivations exist, but they are explicitly mentioned in this manual.

2. Basic Operators

2.1 Addition & Subtraction
Addition is respresented by the plus operator + and subtraction is represented by the minus operator -.
Example: 3.2 + 10 - 0.9 results in 12.3.

2.2 Multiplication & Division
Multiplication is respresented by the * operator and division is represented by the / operator.
Example: 2 * 2*3 / 5 results in 2.4.

2.3 Modulo
The modulo operation is respresented by the % operator. It calculates the remainder of division of one number by another.
Example: 23 % 5 results in 3.

2.4 Exponentiation
The exponentiation (or power) operation is respresented by the ^ operator.
Example: (30/3) ^ (2+1) results in 1000.

2.5 Binary Left/Right Shift
The binary left shift operation is respresented by the << operator and the binary right shift operation is represented by the >> operator. The bit pattern is given by the left-hand operand, and the number of positions to shift by the right-hand operand. In fact 'x << y' is the same as x * (2^y) and 'x >> y' is the same as x / (2^y). Note that the operands are converted to integers.
Example: 1 << 4 results in 16.
Example: 34.2 >> 2 results in 8.0.

2.6 AND, OR, XOR & NOT Operators
The bitwise AND operation is represented by the & operator. The bitwise Inclusive OR operation is represented by the | operator. The bitwise Exclusive OR (XOR) operation is represented by the # operator. The bitwise COMPLEMENT operation is represented by the ! operator.
Note that the operands are converted to integers except the ! operator - that's a difference to C or Java. The ! operator converts bit by bit, also floating-point numbers without converting them to integers.
Another difference to C/Java is the XOR operator which is represented by the # operator and not by the ^ operator which is here used for exponentiation.
Example: 29 & 23 results in 21.0.
Example: (2+1*2) | 8 results in 12.0.

Example: 4.33 # 5.1 results in 1.0.
Example: !110.625 results in 17.25.

2.7 Operator Precedence
The available operaters, shown in order of presedence - from highest to lowest.

!
Complement
^
Exponentiation
%
Modulo
/
Division
*
Multiplication
+
Addition
-
Subtraction
<<
Left Shift
>>
Right Shift
#
XOR
&
AND
|
OR

 

3. Functions

3.1 Square Root (sqrt)
Returns the correctly rounded positive square root of the given value.
Example: sqrt(36.98) results in 6.081118318204308.

3.2 Sinus (sin)
Returns the trigonometric sine of an angle in radians.
Example: sin(1.2) results in 0.9320390859672263.

3.3 Cosinus (cos)
Returns the trigonometric cosine of an angle in radians.
Example: cos(1.2) results in 1.0.

3.4 Tangent (tan)
Returns the trigonometric tangent of an angle in radians.
Example: tan(0) results in 0.0.

3.5 Natural Logarithm (log)
Returns the natural logarithm (base e) of the given value.
Example: log(e+1) results in 1.3132616875182228.

3.6 Base 10 Logarithm (log10)
Returns the base 10 logarithm of the given value.
Example: log10(100) results in 2.0.

3.7 Arcus Sinus (asin)
Returns the arc sine of an angle, in the range of -pi/2 through pi/2.
Example: asin(1.0) results in 1.5707963267948966.

3.8 Arcus Cosinus (acos)
Returns the arc cosine of an angle, in the range of 0.0 through pi.
Example: acos(-1) results in 3.141592653589793.

3.9 Arcus Tangent (atan)
Returns the arc tangent of an angle, in the range of -pi/2 through pi/2.
Example: atan(100) results in 1.5607966601082315.

3.10 Hyperbolic Sinus (sinh)
Returns the hyperbolic sine of the given value. The hyperbolic sine of x is defined to be (ex - e-x)/2 where e is Euler's number.
Example: sinh(4) results in 27.28991719712775.

3.11 Hyperbolic Cosinus (cosh)
Returns the hyperbolic cosine of the given value. The hyperbolic cosine of x is defined to be (ex + e-x)/2 where e is Euler's number.
Example: cosh(((3+4+3)*(0.4/2/2))) results in 1.543080634815244.

3.12 Hyperbolic Tangent (tanh)
Returns the hyperbolic tangent of the given value. The hyperbolic tangent of x is defined to be sinh(x)/cosh(x). Note that the absolute value of the exact tanh is always less than 1.
Example: tanh(2) results in 0.9640275800758169.

3.13 Converting Radians to Degress (todeg)
Converts an angle measured in radians to an approximately equivalent angle measured in degrees.
Example: todeg(pi) results in 180.0.

3.14 Converting Degrees to Radians (torad)
Converts an angle measured in degrees to an approximately equivalent angle measured in radians.
Example: torad(360) results in 6.283185307179586.

3.15 Round (round)
Rounds the given value to the closest integer.
Example: round(11.81) results in 12.0.

3.16 Floor (floor)
Returns the largest integer which is less or equal to the given value.
Example: floor(11.81) results in 11.0.



4. Constants

Following constants are recognized:
pi : equals 3.141592653589793.
e : Euler's Number, equals 2.718281828459045.

 

5. Numerical Systems

5.1 Specify a number in a different base
You can specify a number in an arbitrary base (between 2 and 36) by appending an '@' followed by the base.
Example: 1101@2 means to interpret 1101 in base 2 which results in 13.0.
Of course, you can uese such expressions everywhere where you are able to use base10 numbers:
Example: 11@2 * ff@16 + a@17 results in 775.0.

5.2 Specify the result in a different base
If you want to receive the result also in another base than base 10, you can check the checkbox under the expression field and select your additional desired base from the dropdown list.

 

6. About / Info

This applet was originally coded for personal reasons cause I always forgot to take along my hand calculator and the windows/linux calculators do not satisfy my needs nor are they comfortable to use. After finishing coding I decided to make it public in case someone else finds it useful.
I am gonna to release the full source code somewhere in future, but not before all bugs are removed - therefore I need your help:

If you find any bugs, have suggestions or commens - please mail me:

6.1 History
2nd July 2008: Version 1.0
* Initial release

5th September 2008:
Version 1.1
* fixed two small bugs in the parser
* added the autocompletion feature

16th December 2008: Version 1.1
* released the source
::Download:: (120 kb) - applet, source, manual

Sunshine, December 2008


This site is part of Sunshine's Homepage