C# Class Pchp.Library.PhpMath

Implements PHP mathematical functions and constants.
Afficher le fichier Open project: iolevel/peachpie

Private Properties

Свойство Type Description
AbsolutizeRange void
BaseToDouble double
ConvertToLong PhpNumber
DoubleToBase string
FindExtreme Pchp.Core.PhpValue
GetExtreme Pchp.Core.PhpValue
Power10Value double
Random01 int
RoundInternal double
_Log10Abs int
base_convert string

Méthodes publiques

Méthode Description
abs ( PhpNumber x ) : PhpNumber

Returns the absolute value of x.

abs ( long lx ) : PhpNumber
abs ( double x ) : double
acos ( double x ) : double

Returns the arc cosine of arg in radians. acos() is the complementary function of cos(), which means that x==cos(acos(x)) for every value of a that is within acos()' range.

acosh ( double x ) : double
asin ( double x ) : double

Returns the arc sine of arg in radians. asin() is the complementary function of sin(), which means that x==sin(asin(x)) for every value of a that is within asin()'s range.

asinh ( double x ) : double
atan ( double x ) : double
atan2 ( double y, double x ) : double
atanh ( double x ) : double
bindec ( string str ) : PhpNumber

Returns the decimal equivalent of the binary number represented by the binary_string argument. bindec() converts a binary number to an integer or, if needed for size reasons, double.

ceil ( double x ) : double

Returns the next highest integer value by rounding up x if necessary.

cos ( double x ) : double
cosh ( double x ) : double
decbin ( double number ) : string

Converts the lowest 32 bits of the given number to a binary string.

dechex ( long number ) : string

Returns a string containing a hexadecimal representation of the given number argument.

decoct ( int number ) : string

Returns a string containing an octal representation of the given number argument.

deg2rad ( double degrees ) : double

Degrees to radians.

exp ( double x ) : double

Returns e raised to the power of x.

expm1 ( double x ) : double

expm1() returns the equivalent to 'exp(arg) - 1' computed in a way that is accurate even if the value of arg is near zero, a case where 'exp (arg) - 1' would be inaccurate due to subtraction of two numbers that are nearly equal.

floor ( double x ) : double

Returns the next lowest integer value by rounding down x if necessary.

fmod ( double x, double y ) : double

Returns the floating point remainder (modulo) of the division of the arguments.

getrandmax ( ) : int

Show largest possible random value.

hexdec ( string str ) : PhpNumber

Hexadecimal to decimal. Returns the decimal equivalent of the hexadecimal number represented by the hex_string argument. hexdec() converts a hexadecimal string to a decimal number. hexdec() will ignore any non-hexadecimal characters it encounters.

hypot ( double x, double y ) : double
is_finite ( double x ) : bool
is_infinite ( double x ) : bool
is_nan ( double x ) : bool
lcg_value ( ) : double

Generates a pseudo-random number using linear congruential generator in the range of (0,1).

This method uses the Framwork rand() generator which may or may not be the same generator as the PHP one (L(CG(2^31 - 85),CG(2^31 - 249))).

log ( double x ) : double
log ( double x, double logBase ) : double

If the optional logBase parameter is specified, log() returns log(logBase) x, otherwise log() returns the natural logarithm of x.

log10 ( double x ) : double

Returns the base-10 logarithm of x.

log1p ( double x ) : double

log1p() returns log(1 + number) computed in a way that is accurate even when the value of number is close to zero. log() might only return log(1) in this case due to lack of precision.

max ( ) : PhpValue

Find highest value. If the first and only parameter is an array, max() returns the highest value in that array. If at least two parameters are provided, max() returns the biggest of these values.

max ( PhpArray array ) : PhpValue

Find highest value.

max ( long a, long b ) : long

Find highest value.

min ( ) : PhpValue

Find lowest value. If the first and only parameter is an array, min() returns the lowest value in that array. If at least two parameters are provided, min() returns the smallest of these values.

min ( PhpArray array ) : PhpValue

Find lowest value.

min ( long a, long b ) : long

Find lowest value.

mt_getrandmax ( ) : int
mt_rand ( ) : int
mt_rand ( int min, int max ) : int
mt_srand ( ) : void

Seed the better random number generator. No return value.

mt_srand ( int seed ) : void

Seed the better random number generator. No return value.

octdec ( string str ) : PhpNumber

Returns the decimal equivalent of the octal number represented by the str argument.

pi ( ) : double

Returns an approximation of pi.

pow ( PhpNumber @base, PhpNumber exp ) : PhpNumber

Returns base raised to the power of exp.

rad2deg ( double radians ) : double

Radians to degrees.

rand ( ) : int

Generate a random integer.

rand ( int min, int max ) : int

Generate a random integer.

round ( double x ) : double

Rounds a float.

round ( double x, int precision ) : double

Rounds a float.

round ( double x, int precision, RoundMode mode = RoundMode.HalfUp ) : double

Rounds a float.

sin ( double x ) : double
sinh ( double x ) : double
sqrt ( double x ) : double
srand ( ) : void

Seed the random number generator. No return value.

srand ( int seed ) : void

Seed the random number generator. No return value.

tan ( double x ) : double
tanh ( double x ) : double
uniqid ( ) : string

Generate a unique ID. Gets a prefixed unique identifier based on the current time in microseconds.

uniqid ( string prefix ) : string

Generate a unique ID. Gets a prefixed unique identifier based on the current time in microseconds.

uniqid ( string prefix, bool more_entropy ) : string

Generate a unique ID.

With an empty prefix, the returned string will be 13 characters long. If more_entropy is TRUE, it will be 23 characters.

Private Methods

Méthode Description
AbsolutizeRange ( int &offset, int &length, int count ) : void

Absolutizes range specified by an offset and a length relatively to a dimension of an array.

Ensures that [offset,offset + length] is subrange of [0,count].

BaseToDouble ( string number, int fromBase ) : double
ConvertToLong ( double number ) : PhpNumber

Converts the given number to int64 (if the number is whole and fits into the int64's range).

DoubleToBase ( double number, int toBase ) : string
FindExtreme ( IEnumerable array, bool maximum ) : PhpValue
GetExtreme ( PhpValue numbers, bool maximum ) : PhpValue
Power10Value ( int power ) : double

Returns precise value of 10^power.

Random01 ( ) : int

Gets 0 or 1 randomly.

RoundInternal ( double value, RoundMode mode ) : double
_Log10Abs ( double value ) : int
base_convert ( string number, int fromBase, int toBase ) : string

Method Details

abs() public static méthode

Returns the absolute value of x.
public static abs ( PhpNumber x ) : PhpNumber
x PhpNumber The numeric value to process.
Résultat PhpNumber

abs() public static méthode

public static abs ( long lx ) : PhpNumber
lx long
Résultat PhpNumber

abs() public static méthode

public static abs ( double x ) : double
x double
Résultat double

acos() public static méthode

Returns the arc cosine of arg in radians. acos() is the complementary function of cos(), which means that x==cos(acos(x)) for every value of a that is within acos()' range.
public static acos ( double x ) : double
x double The argument to process.
Résultat double

acosh() public static méthode

public static acosh ( double x ) : double
x double
Résultat double

asin() public static méthode

Returns the arc sine of arg in radians. asin() is the complementary function of sin(), which means that x==sin(asin(x)) for every value of a that is within asin()'s range.
public static asin ( double x ) : double
x double The argument to process.
Résultat double

asinh() public static méthode

public static asinh ( double x ) : double
x double
Résultat double

atan() public static méthode

public static atan ( double x ) : double
x double
Résultat double

atan2() public static méthode

public static atan2 ( double y, double x ) : double
y double
x double
Résultat double

atanh() public static méthode

public static atanh ( double x ) : double
x double
Résultat double

bindec() public static méthode

Returns the decimal equivalent of the binary number represented by the binary_string argument. bindec() converts a binary number to an integer or, if needed for size reasons, double.
public static bindec ( string str ) : PhpNumber
str string The binary string to convert.
Résultat PhpNumber

ceil() public static méthode

Returns the next highest integer value by rounding up x if necessary.
public static ceil ( double x ) : double
x double The value to round.
Résultat double

cos() public static méthode

public static cos ( double x ) : double
x double
Résultat double

cosh() public static méthode

public static cosh ( double x ) : double
x double
Résultat double

decbin() public static méthode

Converts the lowest 32 bits of the given number to a binary string.
public static decbin ( double number ) : string
number double
Résultat string

dechex() public static méthode

Returns a string containing a hexadecimal representation of the given number argument.
public static dechex ( long number ) : string
number long Decimal value to convert.
Résultat string

decoct() public static méthode

Returns a string containing an octal representation of the given number argument.
public static decoct ( int number ) : string
number int Decimal value to convert.
Résultat string

deg2rad() public static méthode

Degrees to radians.
public static deg2rad ( double degrees ) : double
degrees double
Résultat double

exp() public static méthode

Returns e raised to the power of x.
public static exp ( double x ) : double
x double
Résultat double

expm1() public static méthode

expm1() returns the equivalent to 'exp(arg) - 1' computed in a way that is accurate even if the value of arg is near zero, a case where 'exp (arg) - 1' would be inaccurate due to subtraction of two numbers that are nearly equal.
public static expm1 ( double x ) : double
x double The argument to process
Résultat double

floor() public static méthode

Returns the next lowest integer value by rounding down x if necessary.
public static floor ( double x ) : double
x double The numeric value to round.
Résultat double

fmod() public static méthode

Returns the floating point remainder (modulo) of the division of the arguments.
public static fmod ( double x, double y ) : double
x double The dividend.
y double The divisor.
Résultat double

getrandmax() public static méthode

Show largest possible random value.
public static getrandmax ( ) : int
Résultat int

hexdec() public static méthode

Hexadecimal to decimal. Returns the decimal equivalent of the hexadecimal number represented by the hex_string argument. hexdec() converts a hexadecimal string to a decimal number. hexdec() will ignore any non-hexadecimal characters it encounters.
public static hexdec ( string str ) : PhpNumber
str string The hexadecimal string to convert.
Résultat PhpNumber

hypot() public static méthode

public static hypot ( double x, double y ) : double
x double
y double
Résultat double

is_finite() public static méthode

public static is_finite ( double x ) : bool
x double
Résultat bool

is_infinite() public static méthode

public static is_infinite ( double x ) : bool
x double
Résultat bool

is_nan() public static méthode

public static is_nan ( double x ) : bool
x double
Résultat bool

lcg_value() public static méthode

Generates a pseudo-random number using linear congruential generator in the range of (0,1).
This method uses the Framwork rand() generator which may or may not be the same generator as the PHP one (L(CG(2^31 - 85),CG(2^31 - 249))).
public static lcg_value ( ) : double
Résultat double

log() public static méthode

public static log ( double x ) : double
x double
Résultat double

log() public static méthode

If the optional logBase parameter is specified, log() returns log(logBase) x, otherwise log() returns the natural logarithm of x.
public static log ( double x, double logBase ) : double
x double
logBase double
Résultat double

log10() public static méthode

Returns the base-10 logarithm of x.
public static log10 ( double x ) : double
x double
Résultat double

log1p() public static méthode

log1p() returns log(1 + number) computed in a way that is accurate even when the value of number is close to zero. log() might only return log(1) in this case due to lack of precision.
public static log1p ( double x ) : double
x double The argument to process
Résultat double

max() public static méthode

Find highest value. If the first and only parameter is an array, max() returns the highest value in that array. If at least two parameters are provided, max() returns the biggest of these values.
public static max ( ) : PhpValue
Résultat Pchp.Core.PhpValue

max() public static méthode

Find highest value.
public static max ( PhpArray array ) : PhpValue
array Pchp.Core.PhpArray
Résultat Pchp.Core.PhpValue

max() public static méthode

Find highest value.
public static max ( long a, long b ) : long
a long
b long
Résultat long

min() public static méthode

Find lowest value. If the first and only parameter is an array, min() returns the lowest value in that array. If at least two parameters are provided, min() returns the smallest of these values.
public static min ( ) : PhpValue
Résultat Pchp.Core.PhpValue

min() public static méthode

Find lowest value.
public static min ( PhpArray array ) : PhpValue
array Pchp.Core.PhpArray
Résultat Pchp.Core.PhpValue

min() public static méthode

Find lowest value.
public static min ( long a, long b ) : long
a long
b long
Résultat long

mt_getrandmax() public static méthode

public static mt_getrandmax ( ) : int
Résultat int

mt_rand() public static méthode

public static mt_rand ( ) : int
Résultat int

mt_rand() public static méthode

public static mt_rand ( int min, int max ) : int
min int
max int
Résultat int

mt_srand() public static méthode

Seed the better random number generator. No return value.
public static mt_srand ( ) : void
Résultat void

mt_srand() public static méthode

Seed the better random number generator. No return value.
public static mt_srand ( int seed ) : void
seed int Optional seed value.
Résultat void

octdec() public static méthode

Returns the decimal equivalent of the octal number represented by the str argument.
public static octdec ( string str ) : PhpNumber
str string The octal string to convert.
Résultat PhpNumber

pi() public static méthode

Returns an approximation of pi.
public static pi ( ) : double
Résultat double

pow() public static méthode

Returns base raised to the power of exp.
public static pow ( PhpNumber @base, PhpNumber exp ) : PhpNumber
@base PhpNumber
exp PhpNumber
Résultat PhpNumber

rad2deg() public static méthode

Radians to degrees.
public static rad2deg ( double radians ) : double
radians double
Résultat double

rand() public static méthode

Generate a random integer.
public static rand ( ) : int
Résultat int

rand() public static méthode

Generate a random integer.
public static rand ( int min, int max ) : int
min int The lowest value to return.
max int The highest value to return.
Résultat int

round() public static méthode

Rounds a float.
public static round ( double x ) : double
x double The value to round.
Résultat double

round() public static méthode

Rounds a float.
public static round ( double x, int precision ) : double
x double The value to round.
precision int The optional number of decimal digits to round to. Can be less than zero to ommit digits at the end. Default is 0.
Résultat double

round() public static méthode

Rounds a float.
public static round ( double x, int precision, RoundMode mode = RoundMode.HalfUp ) : double
x double The value to round.
precision int The optional number of decimal digits to round to. Can be less than zero to ommit digits at the end. Default is 0.
mode RoundMode One of PHP_ROUND_HALF_UP, PHP_ROUND_HALF_DOWN, PHP_ROUND_HALF_EVEN, or PHP_ROUND_HALF_ODD. Default is PHP_ROUND_HALF_UP.
Résultat double

sin() public static méthode

public static sin ( double x ) : double
x double
Résultat double

sinh() public static méthode

public static sinh ( double x ) : double
x double
Résultat double

sqrt() public static méthode

public static sqrt ( double x ) : double
x double
Résultat double

srand() public static méthode

Seed the random number generator. No return value.
public static srand ( ) : void
Résultat void

srand() public static méthode

Seed the random number generator. No return value.
public static srand ( int seed ) : void
seed int Optional seed value.
Résultat void

tan() public static méthode

public static tan ( double x ) : double
x double
Résultat double

tanh() public static méthode

public static tanh ( double x ) : double
x double
Résultat double

uniqid() public static méthode

Generate a unique ID. Gets a prefixed unique identifier based on the current time in microseconds.
public static uniqid ( ) : string
Résultat string

uniqid() public static méthode

Generate a unique ID. Gets a prefixed unique identifier based on the current time in microseconds.
public static uniqid ( string prefix ) : string
prefix string Can be useful, for instance, if you generate identifiers simultaneously on several hosts that might happen to generate the identifier at the same microsecond. /// With an empty prefix , the returned string will be 13 characters long. ///
Résultat string

uniqid() public static méthode

Generate a unique ID.
With an empty prefix, the returned string will be 13 characters long. If more_entropy is TRUE, it will be 23 characters.
public static uniqid ( string prefix, bool more_entropy ) : string
prefix string Use the specified prefix.
more_entropy bool Use LCG to generate a random postfix.
Résultat string