VBScript Math References

 

Abs Function
Atn Function
Cos Function
Exp Function
Int, Fix Function
Log Function
Rnd Function
Sgn Function
Sin Function
Sqr Function
Tan Function

Derived Math Functions

Operator Precedence

Data ranges

Numeric expression

 

Abs Function

Description

Returns the absolute value of a number.

Syntax

Abs(number)


Atn Function

Description

Returns the arctangent of a number.

Syntax

Atn(number)

The number argument can be any valid numeric expression.


Cos Function

Description

Returns the cosine of an angle.

Syntax

Cos(number)


Exp Function

Description

Returns e (the base of natural logarithms) raised to a power.

Syntax

Exp(number)


Int, Fix Function

Description

Returns the integer portion of a number.

Syntax

Int(number)

Fix(number)


Log Function

Description

Returns the natural logarithm of a number.

Syntax

Log(number)

The number argument can be any valid numeric expression greater than 0.

 


Rnd Function

Description

Returns a random number.

Syntax

Rnd[(number)]

The number argument can be any valid numeric expression.


Sgn Function

Description

Returns an integer indicating the sign of a number.

Syntax

Sgn(number)

The number argument can be any valid numeric expression.


Sin Function

Description

Returns the sine of an angle.

Syntax

Sin(number)

The number argument can be any valid numeric expression that expresses an angle in radians.

Remarks


Sqr Function

Description

Returns the square root of a number.

Syntax

Sqr(number)

The number argument can be any valid numeric expression greater than or equal to 0.


Tan Function

Description

Returns the tangent of an angle.

Syntax

Tan(number)

The number argument can be any valid numeric expression that expresses an angle in radians.



 

 

Derived Math Functions

Description

The following nonintrinsic math functions can be derived from the intrinsic math functions:

Function

Derived equivalents

Secant

Sec(X) = 1 / Cos(X)

Cosecant

Cosec(X) = 1 / Sin(X)

Cotangent

Cotan(X) = 1 / Tan(X)

Inverse Sine

Arcsin(X) = Atn(X / Sqr(-X * X + 1))

Inverse Cosine

Arccos(X) = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1)

Inverse Secant

Arcsec(X) = Atn(X / Sqr(X * X - 1)) + Sgn((X) -1) * (2 * Atn(1))

Inverse Cosecant

Arccosec(X) = Atn(X / Sqr(X * X - 1)) + (Sgn(X) - 1) * (2 * Atn(1))

Inverse Cotangent

Arccotan(X) = Atn(X) + 2 * Atn(1)

Hyperbolic Sine

HSin(X) = (Exp(X) - Exp(-X)) / 2

Hyperbolic Cosine

HCos(X) = (Exp(X) + Exp(-X)) / 2

Hyperbolic Tangent

HTan(X) = (Exp(X) - Exp(-X)) / (Exp(X) + Exp(-X))

Hyperbolic Secant

HSec(X) = 2 / (Exp(X) + Exp(-X))

Hyperbolic Cosecant

HCosec(X) = 2 / (Exp(X) - Exp(-X))

Hyperbolic Cotangent

HCotan(X) = (Exp(X) + Exp(-X)) / (Exp(X) - Exp(-X))

Inverse Hyperbolic Sine

HArcsin(X) = Log(X + Sqr(X * X + 1))

Inverse Hyperbolic Cosine

HArccos(X) = Log(X + Sqr(X * X - 1))

Inverse Hyperbolic Tangent

HArctan(X) = Log((1 + X) / (1 - X)) / 2

Inverse Hyperbolic Secant

HArcsec(X) = Log((Sqr(-X * X + 1) + 1) / X)

Inverse Hyperbolic Cosecant

HArccosec(X) = Log((Sgn(X) * Sqr(X * X + 1) +1) / X)

Inverse Hyperbolic Cotangent

HArccotan(X) = Log((X + 1) / (X - 1)) / 2

Logarithm to base N

LogN(X) = Log(X) / Log(N)

 


Operator Precedence

 

Arithmetic

Comparison

Logical

Exponentiation (^)

Equality (=)

Not

Negation (-)

Inequality (<>)

And

Multiplication and division (*, /)

Less than (<)

Or

Integer division (\)

Greater than (>)

Xor

Modulus arithmetic (Mod)

Less than or equal to (<=)

Eqv

Addition and subtraction (+, -)

Greater than or equal to (>=)

Imp

String concatenation (&)

Is

&

 


Data ranges

Each Variant subtype has a specific range of allowed values:

Subtype

Range

Byte

0 to 255.

Boolean

True or False.

Integer

-32,768 to 32,767.

Long

-2,147,483,648 to 2,147,483,647.

Single

-3.402823E38 to -1.401298E-45 for negative values; 1.401298E-45 to 3.402823E38 for positive values.

Double

-1.79769313486232E308 to -4.94065645841247E-324 for negative values; 4.94065645841247E-324 to 1.79769313486232E308 for positive values.

Currency

-922,337,203,685,477.5808 to 922,337,203,685,477.5807.

Date

January 1, 100 to December 31, 9999, inclusive.

Object

Any Object reference.

String

Variable-length strings may range in length from 0 to approximately 2 billion characters.

 

Numeric expression

Any expression that can be evaluated as a number. Elements of the expression can include any combination of keywords, variables, constants, and operators that result in a number.