Last updated Sunday, November 18, 2001.
Given a number value, an absolute value function returns the positive value of value. For example, given the value 15, it returns 15.
C / C++ 
TODO: Fill this in. 
C# 
Abs functionusing System.Math; Abs(value) 
Java 
TODO: Fill this in. 
Python 
abs functionabs(value) The type of the return value is the same as the argument (int or float).
fabs functionfrom math import fabs fabs(value) Like the abs function, except that the return type is always a float. 
RB 
abs(value) 
VB 6  abs(value) 
VB .NET 
Abs functionimports System.Math Abs(value) 
C / C++ 
TODO: Fill this in. 
C# 
Ceiling static methodusing System.Math; Ceiling(value) This function returns a double. According to the MSDN documentation, "the behavior of this method follows IEEE Standard 754, section 4." 
Java 
TODO: Fill this in. 
Python 
ceil functionfrom math import ceil ceil(value) Returns a float containing value rounded up to the nearest integer. 
RB 
ceil functionceil(value as Double) Returns a double containing value rounded up to the nearest integer. 
VB 6 
Use custom function: ceilVB 6 doesn't have a builtin ceiling function. Use the code below: public function Ceil(value
as double) This code takes advantage of the fact that CLng rounds to the nearest decimal. To force it to always round up, .5 is added to its argument. Since this implementation of the ceiling function uses a function that converts value to a long, it will only work for values between 2,147,483,648 and 2,147,483,647 (the range of numbers that can be handled by a long). 
VB .NET 
Ceiling shared methodimports System.Math Ceiling(value) This function returns a double. According to the MSDN documentation, "the behavior of this method follows IEEE Standard 754, section 4." 
C / C++ 
TODO: Fill this in. 
C# 
Exp static methodusing System.Math; Exp(value) This function returns a double. 
Java 
TODO: Fill this in. 
Python 
exp functionfrom math import exp exp(value) This function returns a float. 
RB 
exp functionexp(value as Double) This function returns a double. 
VB 6 
exp functionexp(value as number) This function returns a double. 
VB .NET 
Exp shared methodimports System.Math Exp(value) This function returns a double. 
C / C++ 
TODO: Fill this in. 
C# 
Pow static methodusing System.Math; Pow(base, power) This function returns a double. 
Java 
TODO: Fill this in. 
Python 
** operatorbase ** power Returns base raised to the powerth power. The result is an int if both base and power are ints, otherwise the result is a float.
pow functionfrom math import pow pow(base, power) Returns a float containing base raised to the powerth power. 
RB 
Pow functionPow(base as Double, power as Double) Returns a double containing base raised to the powerth power. 
VB 6 
^ operatorbase ^ power Returns a double containing base raised to the powerth power.The ^ operator is more in line with "traditional" versions of BASIC than RB’s Pow function. 
VB .NET 
Pow shared methodimports System.Math Pow(base, power) This function returns a double. 
C / C++ 
TODO: Fill this in. 
C# 
Floor static methodusing System.Math; Floor(value) This function returns a double. According to the MSDN documentation, "the behavior of this method follows IEEE Standard 754, section 4." 
Java 
TODO: Fill this in. 
Python 
floor functionfrom math import floor floor(value) Returns a float containing value rounded down to the nearest integer. 
RB 
floor functionfloor(value as Double) Returns a double containing value rounded down to the nearest integer. 
VB 6 
Use custom function: floorVB 6 doesn't have a builtin ceiling function. Use the code below: public function Floor(value
as double) This code takes advantage of the fact that CLng rounds to the nearest decimal. To force it to always round down, .5 is subtracted from its argument. Since this implementation of the ceiling function uses a function that converts value to a long, it will only work for values between 2,147,483,648 and 2,147,483,647 (the range of numbers that can be handled by a long). 
VB .NET 
Floor shared methodimports System.Math Floor(value) This function returns a double. According to the MSDN documentation, "the behavior of this method follows IEEE Standard 754, section 4." 
C / C++ 
TODO: Fill this in. 
C# 
TODO: Fill this in. 
Java 
TODO: Fill this in. 
Python 
from math import modf modf(value) Returns a 2tuple of floats containing the fractional and integer parts of value, in that order. 
RB 
TODO: Fill this in. 
VB 
TODO: Fill this in. 
C / C++ 
TODO: Fill this in. 
C# 
TODO: Fill this in. 
Java 
TODO: Fill this in. 
Python 
from math import hypot hypot(x, y) Returns a float containing the length of the hypotenuse of a rightangled triangle having width x and height y. 
RB 
TODO: Fill this in. 
VB 
TODO: Fill this in. 
C / C++ 
TODO: Fill this in. 
C# 
Log static method, base eusing System.Math; Log(value) This function returns a double.
Log10 static methodusing System.Math; Log10(value) This function returns a double containing the base 10 logarithm of value.
Log static method, any baseusing System.Math; Log(value, base) This function returns a double containing the logarithm of value in the given base. 
Java 
TODO: Fill this in. 
Python 
log functionfrom math import log log(value) Returns a float containing the natural logarithm (base e) of value.
log10 functionfrom math import log10 log10(value) Returns a float containing the base 10 logarithm of value. 
RB 
log functionlog(value as Double) Returns a double containing the natural logarithm (base e) of value. 
VB 6 
log functionLog(value as number) Returns a double containing the natural logarithm (base e) of value. 
VB .NET 
Log shared method, base eimports System.Math Log(value) This function returns a double.
Log10 shared methodimports System.Math Log10(value) This function returns a double containing the base 10 logarithm of value.
Log shared method, any baseimports System.Math Log(value, base) This function returns a double containing the logarithm of value in the given base. 
The base of the logarithm functions in most programming is the transcendental number e (approximate value 2.718282)  what both they refer to as Log(x), math people would call "ln(x)" (and is often pronounced "lawn of x").
A logarithm is simply the inverse of exponentiation, just as subtraction is the inverse of addition. As exponentiation answers the question "What is the value of the nth power of x?", logarithms answer the question "What power of x gets me y?" For example, the base 5 logarithm of 625 is 4 (because 5 raised to the 4th power is 625), and the base 25 logarithm of 625 is 2 (since 25 squared is 625).
"But wait," you say, "I'm stuck with base e logarithms!" That's okay, because you can calculate the base n logarithm for any number x by using this formula: Logn(x) = Log(x) / Log(n). Suppose you wanted to knew that the number 65,536 is a power 2, but didn't know which power of 2. You'd simply use the formula Log(65536)/Log(2) to get 16, which is correct, since 2 to the 16th power is 65,536.
Logarithms used to be an indispensable calculating aid before the days of adding machines. People used to publish tables of logarithms of numbers to make calculation easier (slide rules are essentially mechanized logarithm tables). I won't go into the details of why it's so, but rather than multiply two very large numbers xand y to get z (which is tedious and errorprone), it's much easier to add log(x) and log(y) to get log(z) and then see what number corresponds to log(z) in a table.
Logarithms are used to make dealing with extremely big numbers or wide ranges of numbers easier since small logarithms are associated with big numbers. The Richter scale for measuring the intensity of earthquakes is a base10 logarithmic scale; for example an earthquake that is rated 6 is ten times as powerful as one that rated 5 and 100 times as powerful as one that rated 4.
C / C++ 
TODO: Fill this in. 
C# 
Max static methodusing System.Math; Max(value1, value2) value1 and value2 must be of the same type. This function returns a value of the same type as value1 and value2. 
Java 
TODO: Fill this in. 
Python 
max functionmax(value1, value2, value3, ... , valueN) The type of the returned value is the type of the largest value. 
RB 
max functionmax(number1 as Double, number2 as Double) This function returns a double. 
VB 6 
Use custom function: MaxVB 6 doesn't have a builtin max function. Use the code below: Function Max(value1
as Double, value2 as Double) as Double This function is modelled to be equivalent to RB's Max function. VB 6 does have a function called Max, but it’s used to find the largest value of a database field and not for comparing two numbers. 
VB .NET 
Max shared methodimports System.Math Max(value1, value2) value1 and value2 must be of the same type. This function returns a value of the same type as value1 and value2. 
C / C++ 
TODO: Fill this in. 
C# 
Min static methodusing System.Math; Min(value1, value2) value1 and value2 must be of the same type. This function returns a value of the same type as value1 and value2. 
Java 
TODO: Fill this in. 
Python 
min functionmin(value1, value2, value3, ... , valueN) The type of the returned value is the type of the smallest value. 
RB 
min functionMin(number1 as Double, number2 as Double) This function returns a double. 
VB 6 
Use custom function: MinVB 6 doesn't have a builtin min function. Use the code below: Function Min(value1
as Double, value2 as Double) as Double This function is modelled to be equivalent to RB's Min function. VB 6 does have a function called Min, but it’s used to find the smallest value of a database field and not for comparing two numbers. 
VB .NET 
Min shared methodimports System.Math Min(value1, value2) value1 and value2 must be of the same type. This function returns a value of the same type as value1 and value2. 
C / C++ 
TODO: Fill this in. 
C# 
Random classThe .NET library provides the Random class for generating random numbers. The Random class provides two constructors:
A random number generator uses its seed value to generate a sequence of pseudorandom numbers. Typically, when you want a new random number, the random number generator provides the next number in that sequence. This is why the Random class' methods for getting random numbers all begin with "Next".
Next methodThe Next method returns a random integer. There are three variations:
NextDouble methodmyRandom.NextDouble() This method returns a random double between 0.0 and 1.0. This method is similar to many other prgramming languages' random number functions.
NextBytes methodmyRandom.NextBytes(myByteArray) This method fills a given array of bytes with random values. 
Java 
TODO: Fill this in. 
Python 
TODO: Fill this in. 
RB 
Rnd functionRnd Returns a double containing a random number between 0 and 1 with seven decimal places. 
VB 
Rnd functionRnd([value])
Randomize functionRandomize([seed]) Returns a double containing a random number between 0 and 1 with seven decimal places.
VB has the Randomize statement, which reseeds the random number generator using seed as a value for "seeding" the generator if seed is provided, or the system timer if seed is not provided. 
VB .NET 
Random classThe .NET library provides the Random class for generating random numbers. The Random class provides two constructors:
A random number generator uses its seed value to generate a sequence of pseudorandom numbers. Typically, when you want a new random number, the random number generator provides the next number in that sequence. This is why the Random class' methods for getting random numbers all begin with "Next".
Next methodThe Next method returns a random integer. There are three variations:
NextDouble methodmyRandom.NextDouble() This method returns a random double between 0.0 and 1.0. This method is similar to many other prgramming languages' random number functions.
NextBytes methodmyRandom.NextBytes(myByteArray) This method fills a given array of bytes with random values. 
C / C++ 
TODO: Fill this in. 
C# 
Round static method, round to nearest integerusing System.Math; Round(value) value must be either a Decimal or a double. This function returns a value of the same type as value.
Round static method, round with specified precisionusing System.Math; Round(value, numberOfDecimals) value must be either a Decimal or a double; numberOfDecimals must be an int. This function returns value rounded to numberOfDecimals decimal places; the return value is of the same type as value. 
Java 
TODO: Fill this in. 
Python 
round(value[, decimal places])

RB 
Round(value as Double) Returns a double: value rounded to the nearest whole number. 
VB 6 
CInt(value as number or String) CLng(value as number or String) The CInt and CLng functions perform rounding, but also return integer and long values, respectively. To get a double result like RB's Round, use CDbl to convert the integer or long into a double. 
VB .NET 
Round shared method, round to nearest integerimports System.Math Round(value) value must be either a Decimal or a double. This function returns a value of the same type as value.
Round shared method, round with specified precisionimports System.Math Round(value, numberOfDecimals) value must be either a Decimal or a double; numberOfDecimals must be an int. This function returns value rounded to numberOfDecimals decimal places; the return value is of the same type as value. 
C / C++ 
TODO: Fill this in.  
C# 
Sign static methodusing System.Math; Sign(value) This function returns a value of the same type as value. 

Java 
TODO: Fill this in.  
Python 
Use custom function: signPython has no builtin sign function, nor is it in the math module. Use the code below: def Sign(value): 

RB 
Use custom function: signRB has no builtin sign function. Use the code below: Function Sign(value
as double) as integer 

VB 6 
Sgn functionSgn(value) Returns a number indicating the sign of the given number.


VB .NET 
Sign shared methodimports System.Math Sign(value) This function returns a value of the same type as value. 
VB and VBA in a Nutshell has this to say about the Sgn function: "I suppose that someone, somewhere has found a really good use for the Sgn function. However, its usefulness escapes me..." (p. 518).
The Sgn function goes back to the days of BASIC (as opposed to presentday Basic). It has some use in the construction of certain hyperbolic trig formulas (see entry), but aside from that, it doesn't seem terribly useful.
C / C++ 
TODO: Fill this in. 
C# 

Java 
TODO: Fill this in. 
Python 
TODO: Fill this in. 
RB 
Val(string) CDbl(string) Returns a double containing the numeric form of the string number. Val stops reading the string after the first character that isn’t recognized as part of a number. For example, Val("123 Springfield Lane") evaluates as 123.0. Val recognizes the prefixes for hexadecimal (&H) and octal(&O)  it will convert these strings into their decimal equivalent. 
VB 
Val(string) CByte(expression) CCur(expression) CDbl(expression) CDec(expression) CInt(expression) CLng(expression) CSng(expression) Val returns a double containing the numeric form of the string number. Val stops reading the string after the first character that isn’t recognized as part of a number. For example, Val("123 Springfield Lane") evaluates as 123.0. 
C / C++ 
TODO: Fill this in. 
C# 
Sqrt static methodusing System.Math; Sqrt(value) This function expects a double and returns a double. 
Java 
TODO: Fill this in. 
Python 
sqrt functionfrom math import sqrt sqrt(value) This function returns a float. 
RB 
Sqrt functionSqrt(value as Double) This function returns a double. 
VB 6 
Sqr functionSqr(value as number) This function returns a double. 
VB .NET 
Sqrt shared methodimports System.Math Sqrt(value) This function expects a double and returns a double. 
Cbased languages 
value1 & value2 
Python 
value1 & value2 
RB 
BitwiseAnd(value1 as Integer, value2 as Integer) Returns a double containing the decimal value equivalent to the result of a bitwise AND operation on the binary values of value1 and value2. 
VB 
value1 And value2 Returns a decimal value equivalent to the result of a bitwise AND operation on the binary values of value1 and value2. value1 and value2 can be any valid numeric expression. If either value1 or value2 contain a fractional part, they are first rounded to the nearest whole number and then the And operation is performed. 
The chart below shows the results of a bitwise And operation for each bit in value1 and value2.
if a bit in value1 is  and the corresponding bit in value2 is  then the corresponding bit in the result is 
0  0  0 
0  1  0 
1  0  0 
1  1  1 
Cbased languages 
expr1 && expr2 
Python 
expr1 and expr2 
RB 
expr1 and expr2 This operator returns True if and only if expr1 and expr2 are both True, otherwise it returns False. expr1 and expr2 can be any valid boolean expression. 
VB 
expr1 and expr2 This operator returns True if and only if expr1 and expr2 are both True, otherwise it returns False. expr1 and expr2 can be any valid boolean expression. 
The chart below shows the results of a logical And operation for expr1 and expr2.
if expr1 evaluates as  and expr2 evaluates as  then the result is 
false  false  false 
false  true  false 
true  false  false 
true  true  true 
value1 Eqv value2
Returns a decimal value equivalent to the result of a bitwise equivalence operation on the binary values of number1 and number2. number1 and number2 can be any valid numeric expression.
No equivalent.
The chart below shows the results of a bitwise Equivalence operation for each bit in value1 and value2.
if a bit in value1 is  and the corresponding bit in value2 is  then the corresponding bit in the result is 
false  false  true 
false  true  false 
true  false  false 
true  true  true 
number1 Eqv number2
Returns a decimal value equivalent to the result of a bitwise equivalence operation on the binary values of number1 and number2. number1 and number2 can be any valid numeric expression.
No equivalent.
The code for a function that emulates VB's Eqv function appears below.
Function VBEqv(expr1 as boolean, expr2 as boolean) as boolean
return (expr1 = expr2)
End Function
The chart below shows the results of a logical Equivalence operation for expr1 and expr2.
if expression1 evaluates as  and expression2 evaluates as  then the result is 
false  false  true 
false  true  false 
true  false  false 
true  true  true 
Cbased languages 
expr1 ^ expr2 
Python 
expr1 ^ expr2 
RB 
expr1 bitwiseXor expr2 Returns a double containing the decimal value equivalent to the result of a bitwise exclusive OR operation on the binary values of value1 and value2. 
VB 
expr1 xor expr2 Returns a decimal value equivalent to the result of a bitwise exclusive OR operation on the binary values of number1 and number2. number1 and number2 can be any valid numeric expression. 
if a bit in value1 is  and the corresponding bit in value2 is  then the corresponding bit in the result is 
0  0  0 
0  1  1 
1  0  1 
1  1  0 
Cbased languages 
expr1 ^^ expr2 
Python 
TODO: Fill this in. 
RB 
No equivalent. Use the following function to emulate an Exclusive Or: Function VBXor(expr1 as boolean, expr2 as boolean) as boolean
End Function 
VB 
expr1 Xor expr2 This operator returns True if either expr1 and expr2  but not both  are True, otherwise it returns False. expr1 and expr2 can be any valid boolean expression. 
The chart below shows the results of a logical Exclusive Or operation for expr1 and expr2.
if expression1 evaluates as  and expression2 evaluates as  then the result is 
false  false  false 
false  true  true 
true  false  true 
true  true  false 
Cbased languages 
TODO: Fill this in. 
Python 
TODO: Fill this in. 
RB 
TODO: Fill this in. 
VB 
number1 Imp number2 Returns a decimal value equivalent to the result of a bitwise implication operation on the binary values of number1 and number2. number1 and number2 can be any valid numeric expression. 
if a bit in value1 is  and the corresponding bit in value2 is  then the corresponding bit in the result is 
0  0  1 
0  1  1 
1  0  0 
1  1  1 
Cbased languages 
TODO: Fill this in. 
Python 
TODO: Fill this in. 
RB 
No equivalent. The implication function below emulates a good portion of VB's Imp function. There is no speciallydefined Null value in RB, so the RB implication function below deals only with true and false values.

VB 
number1 Imp number2 Returns a decimal value equivalent to the result of a bitwise implication operation on the binary values of number1 and number2. number1 and number2 can be any valid numeric expression. 
if expression1 evaluates as  and expression2 evaluates as  then the result is 
false  false  true 
false  true  true 
true  false  false 
true  true  true 
Null  Null  Null 
Null  false  Null 
Null  true  true 
false  Null  true 
true  Null  Null 
Usage Notes
if expression1 evaluates as  and expression2 evaluates as  then the result is 
false  false  true 
false  true  true 
true  false  false 
true  true  true 
Cbased languages 
!expr 
Python 
TODO: Fill this in. 
RB 
TODO: Fill this in. 
VB 
Not arg Returns a decimal value equivalent to the result of a bitwise negation on the binary value arg. arg can be any valid numeric expression. 
if a bit in arg is  and the corresponding bit in the result is 
0  1 
1  0 
Cbased languages 
!expr 
Python 
TODO: Fill this in. 
RB 
Not expr This operator returns True if either expr is False and returns False when expr is True. expr can be any valid boolean expression. 
VB 
Not expr This operator returns True if either expr is False and returns False when expr is True. expr can be any valid boolean expression. 
if expr is  the result is 
false  true 
true  false 
Cbased languages 
value1  value2 
Python 
value1  value2 
RB 
BitwiseOr(value1 as Integer, value2 as Integer) Returns a decimal value equivalent to the result of a bitwise Exlusive Or operation on the binary values of value1 and value2. 
VB 
value1 Or value2 Returns a decimal value equivalent to the result of a bitwise Exlusive Or operation on the binary values of value1 and value2. value1 and value2 can be any valid numeric expression. 
if a bit in value1 is  and the corresponding bit in value2 is  then the corresponding bit in the result is 
0  0  0 
0  1  1 
1  0  1 
1  1  1 
Cbased languages 
expr1  expr2 
Python 
expr1 or expr2 This operator returns True if either expr1 and expr2 (or both) are True, otherwise it returns False. expr1 and expr2 can be any valid boolean expression. 
RB 
expr1 or expr2 This operator returns True if either expr1 and expr2 (or both) are True, otherwise it returns False. expr1 and expr2 can be any valid boolean expression. 
VB 
expr1 or expr2 This operator returns True if either expr1 and expr2 (or both) are True, otherwise it returns False. expr1 and expr2 can be any valid boolean expression. 
The chart below shows the results of a logical Or operation for expr1 and expr2.
if expr1 evaluates as  and expr2 evaluates as  then the result is 
false  false  false 
false  true  true 
true  false  true 
true  true  true 
C / C++ 
TODO: Fill this in. 
C# 
Acos functionusing System.Math; Acos(value) This function returns a double. 
Java 
TODO: Fill this in. 
Python 
acos functionfrom math import acos acos(cosine) This function returns a float. 
RB 
acos functionacos(cosine) This function returns a double. 
VB 6 
Use custom function: acosVB 6 has no builtin arccosine function. Use the function below: public function acos(value)
as double 
VB .NET 
Acos shared methodimports System.Math Acos(value) This function returns a double. 
C / C++ 
TODO: Fill this in. 
C# 
Asin static methodusing System.Math; Asin(value) This function returns a double. 
Java 
TODO: Fill this in. 
Python 
asin functionfrom math import asin asin(sine) This function returns a float. 
RB 
asin functionasin(sine as Double) This function returns a double. 
VB 
No equivalent. You have to roll your own: asin(sine) = atn(sine / sqr(sine * sine + 1) 
VB .NET 
Asin shared methodimports System.Math Asin(value) This function returns a double. 
C / C++ 
TODO: Fill this in. 
C# 
Atan static methodusing System.Math; Atan(value) This function returns a double.
Atan2 static methodusing System.Math; Atan2(y, x) Returns a double containing the angle between the positive xaxis and the point at coordinates (x, y). 
Java 
TODO: Fill this in. 
Python 
atan functionfrom math import atan atan(tangent) Returns a float containing the angle of the given tangent, expressed in radians.
atan2 functionfrom math import atan2 atan2(y, x) Returns a float containing the angle between the positive xaxis and the point at coordinates (x, y). 
RB 
atan functionatan(tangent as Double) This function returns a double. 
VB 
atn functionatn(tangent as number) This function returns a double. 
VB .NET 
Atan shared methodimports System.Math Atan(value) This function returns a double.
Atan2 shared methodimports System.Math Atan2(y, x) Returns a double containing the angle between the positive xaxis and the point at coordinates (x, y). 
C / C++ 
TODO: Fill this in. 
C# 
Cos static methodusing System.Math; Cos(value) This function returns a double. 
Java 
TODO: Fill this in. 
Python 
cos functionfrom math import cos cos(angle) This function returns a float. 
RB 
cos functioncos(angle as Double) This function returns a double. 
VB 
cos functioncos(angle as number) This function returns a double. 
VB .NET 
Cos shared methodimports System.Math Cos(value) This function returns a double. 
Hyperbolic functions are not built into VB, but can be created using the formulas below.
Arcsinh(x) = Log(x + Sqr(x * x + 1))
Arccosh(x) = Log(x + Sqr(x * x  1))
Arctanh(x) = Log((1 + x) / (1  x)) / 2
Arcsech(x) = Log(Sqr(x * x + 1) + 1) / x)
Arccsch(x) = Log((Sgn(x) * Sqr(x * x + 1) + 1) / x)
Arccoth(x) = Log((x + 1) / (x  1)) / 2
These formulas came from VB and VBA in a Nutshell (p. 419).
Hyperbolic functions are not built into RB, but can be built using the formulas above. Note that the Sgn function does not exist in REALBasic; you can create it (see the entry for "Sign fo a number" on this page). Also note that what VB calls Sqr, RB calls Sqrt.
C / C++ 
TODO: Fill this in. 
C# 
Sin static methodusing System.Math; Sin(value) This function returns a double. 
Java 
TODO: Fill this in. 
Python 
sin functionfrom math import sin sin(angle) This function returns a float. 
RB 
sin functionsin(angle as Double) This function returns a double. 
VB 
sin functionsin(angle as number) This function returns a double. 
VB .NET 
Sin shared methodimports System.Math Sin(value) This function returns a double. 
C / C++ 
TODO: Fill this in. 
C# 
Tan static methodusing System.Math; Abs(value) This function returns a double. 
Java 
TODO: Fill this in. 
Python 
tan functionfrom math import tan tan(angle) This function returns a float. 
RB 
tan functiontan(angle) This function returns a double. 
VB 
tan functiontan(angle) This function returns a double. 
VB .NET 
Tan shared methodimports System.Math Abs(value) This function returns a double. 