# JavaScript - Calculator

### Quick and easy calculator

 DecHexOct a = b = c = d =

Enter a numeric expression and press ENTER to calculate.

Get last result by pressing ENTER again.

Use TAB and SHIFT+TAB to jump between fields.

Use SHIFT+Arrows, CTRL+C and CTRL+V to mark, copy and paste.

Variables a to d may be used.

Number format: 123.456E+123

Functions, constants and variables are case sensitive.

 Numeric Operators + Addition -− Subtraction *∙• Multiplication /⁄ Division % Modulus
 Bitwise Operators & Bitwise logic AND | Bitwise logic OR ^ Bitwise logic XOR ~ Bitwise logic NOT << Left shift >> Signed right shift >>> Unsigned right shift

 Mathematical Constants E Euler's Number e, 2.7182… LN2 Natural log of 2, 0.6931… LN10 Natural log of 10, 2.3025… LOG2E Base 2 log of e, 1.4426… LOG10E Base 10 log of e, 0.4342… PIπ Archimedes' Constant π, 3.1415… SQRT1_2 Square root of 1/2, 0.7071… SQRT2 Square root of 2, 1.4142…

 Physical Constants C0 Speed of light in vacuum, 299792458 m/s E0 Vacuum permittivity (electric constant), 8.854187817…E-12 F/m EC Elementary charge, 1.602176634E-19 C G0 Standard gravity, 9.80665 m/s2 GC Gravitational constant, 6.6743E-11 N∙m2/kg2 HC Planck constant, 6.62607015E-34 J∙s KB Boltzmann constant, 1.380649E-23 J/K NA Avogadro constant, 6.02214076E23 mol-1 R Molar gas constant, 8.31446261815324 J/(mol∙K) U0 Vacuum permeability (magnetic constant), 1.2566370614…E-6 N/A2

 Imperial Units FT Foot in m, 0.3048 m/ft IN Inch in mm, 25.4 mm/in LB Pound in kg, 0.45359237 kg/lbm PSI Pound per square inch (lbf/in2) in Pa (N/m2), 6894.757293168 Pa/psi YD Yard in m, 0.9144 m/yd

 Functions abs(x) The absolute value of x acos(x) The arccosine in radians of x acosh(x) The area (inverse) hyperbolic cosine of x acot(x) The arccotangent in radians of x, PI/2 - atan(x) (0 < acot(x) < PI) acoth(x) The area (inverse) hyperbolic cotangent of x, atanh(1/x) acsc(x) The arccosecant in radians of x, asin(1/x) acsch(x) The area (inverse) hyperbolic cosecant of x, asinh(1/x) asec(x) The arcsecant in radians of x, acos(1/x) asech(x) The area (inverse) hyperbolic secant of x, acosh(1/x) asin(x) The arcsine in radians of x asinh(x) The area (inverse) hyperbolic sine of x atan(x) The arctangent in radians of x (-PI/2 < atan(x) < PI/2) atan2(y,x) The arctangent in radians of y/x (-PI < atan2(y,x) < PI) atanh(x) The area (inverse) hyperbolic tangent of x ceil(x) Round up to the nearest integer cos(x) The cosine of x in radians cosh(x) The hyperbolic cosine of x cot(x) The cotangent of x in radians, 1/tan(x) coth(x) The hyperbolic cotangent of x, 1/tanh(x) csc(x) The cosecant of x in radians, 1/sin(x) csch(x) The hyperbolic cosecant of x, 1/sinh(x) date(x) Display date (and time) of day number x day(y,m,d) Convert year, month, day (and hour, min, sec) to day number deg(x) Convert x from radians to degrees deg180(x) Convert x from radians to degrees within -180 to +180 deg360(x) Convert x from radians to degrees within 0 to 360 exp(x) e to the power of x, pow(E,x) fact(x) The factorial of x, x! = Γ(x+1) floor(x) Round down to the nearest integer gamma(x) The gamma of x, Γ(x) = (x-1)! high(x,y) if x ≥ y then 1 else 0 intdiv(x,y) Integer division of x / y log(x) The natural logarithm (base e) of x log10(x) The base 10 logarithm of x log2(x) The base 2 logarithm of x logb(y,x) The base y logarithm of x low(x,y) if x ≤ y then 1 else 0 max(x,y) Gets the number with the highest value min(x,y) Gets the number with the lowest value pow(x,y) The value of x to the power of y, xy rad(x) Convert x from degrees to radians random() Random number between 0 and 1 (0 ≤ random() < 1) range(x,y,z) if x ≥ y and x ≤ z then 1 else 0 round(x) Rounds x to nearest integer (mid point to even) round(x,y) Rounds x to y decimals (nearest integer if y=0) sec(x) The secant of x in radians, 1/cos(x) sech(x) The hyperbolic secant of x, 1/cosh(x) sign(x) if x > 0 then 1 else if x < 0 then -1 else 0 signz(x) if x ≥ 0 then 1 else -1 sin(x) The sine of x in radians sinh(x) The hyperbolic sine of x sqrt(x)√(x) The square root of x tan(x) The tangent of x in radians tanh(x) The hyperbolic tangent of x

The JavaScript syntax and expression parser is used, so exact behavior (precision, precedence, etc.) depends on the client browser.

Some constants and functions are the same as in JavaScript, but many are extensions to the standard JavaScript, and a few have been changed and are not the same as in JavaScript.

This script will execute the user input as JavaScript code, using the eval() function. It is easy to "break" this page with malicious JavaScript code, but this will only affect the client browser itself.

Copyright © 1996-2024 Scandinavian Digital Systems AB
Developed by Anders Danielsson