PHP 클래스 Litipk\BigNumbers\Decimal

저자: Andreu Correa Casablanca ([email protected])
파일 보기 프로젝트 열기: litipk/php-bignumbers 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$value string Internal numeric value

공개 메소드들

메소드 설명
__toString ( ) : string
abs ( ) : Decimal Returns the absolute value (always a positive number)
add ( Decimal $b, integer $scale = null ) : Decimal Adds two Decimal objects
additiveInverse ( ) : Decimal Returns the element's additive inverse.
arccos ( integer $scale = null ) : Decimal Calculates the arccosine of this with the highest possible accuracy
arccot ( integer $scale = null ) : Decimal Calculates the arccotangente of this with the highest possible accuracy
arccsc ( integer $scale = null ) : Decimal Calculates the arccosecant of this with the highest possible accuracy
arcsec ( integer $scale = null ) : Decimal Calculates the arcsecant of this with the highest possible accuracy
arcsin ( integer $scale = null ) : Decimal Calculates the arcsine of this with the highest possible accuracy
arctan ( integer $scale = null ) : Decimal Calculates the arctangente of this with the highest possible accuracy
asFloat ( ) : float Return value as a float
asInteger ( ) : float Return value as a integer
ceil ( integer $scale ) : Decimal "Ceils" the Decimal to have at most $scale digits after the point
comp ( Decimal $b, integer $scale = null ) : integer $this > $b : returns 1 , $this < $b : returns -1 , $this == $b : returns 0
cos ( integer $scale = null ) : Decimal Calculates the cosine of this method with the highest possible accuracy Note that accuracy is limited by the accuracy of predefined PI;
cosec ( integer $scale = null ) : Decimal Calculates the cosecant of this with the highest possible accuracy Note that accuracy is limited by the accuracy of predefined PI;
cotan ( integer $scale = null ) : Decimal Calculates the cotangent of this method with the highest possible accuracy Note that accuracy is limited by the accuracy of predefined PI;
create ( mixed $value, integer $scale = null, boolean $removeZeros = false ) : Decimal Decimal "constructor".
div ( Decimal $b, integer $scale = null ) : Decimal Divides the object by $b .
equals ( Decimal $b, integer $scale = null ) : boolean Equality comparison between this object and $b
exp ( integer $scale = null ) : Decimal Returns exp($this), said in other words: e^$this .
floor ( integer $scale ) : Decimal "Floors" the Decimal to have at most $scale digits after the point
fromDecimal ( Decimal $decValue, integer $scale = null ) : Decimal Constructs a new Decimal object based on a previous one, but changing it's $scale property.
fromFloat ( float $fltValue, integer $scale = null, boolean $removeZeros = false ) : Decimal
fromInteger ( integer $intValue ) : Decimal
fromString ( string $strValue, integer $scale = null, boolean $removeZeros = false ) : Decimal
getNegativeInfinite ( ) : Decimal Returns a "Negative Infinite" object
getPositiveInfinite ( ) : Decimal Returns a "Positive Infinite" object
hasSameSign ( Decimal $b ) : boolean Indicates if the passed parameter has the same sign as the method's bound object.
innerValue ( ) : number Return the inner representation of the class use with caution
isInfinite ( ) : boolean
isInteger ( ) : boolean
isNegative ( ) : boolean
isPositive ( ) : boolean
isZero ( integer $scale = null ) : boolean
log10 ( integer $scale = null ) : Decimal Returns the object's logarithm in base 10
mod ( Decimal $d, integer $scale = null ) Calculate modulo with a decimal
mul ( Decimal $b, integer $scale = null ) : Decimal Multiplies two BigNumber objects
pow ( Decimal $b, integer $scale = null ) : Decimal Powers this value to $b
round ( integer $scale ) : Decimal "Rounds" the Decimal to have at most $scale digits after the point
sec ( integer $scale = null ) : Decimal Calculates the secant of this with the highest possible accuracy Note that accuracy is limited by the accuracy of predefined PI;
sin ( integer $scale = null ) : Decimal Calculates the sine of this method with the highest possible accuracy Note that accuracy is limited by the accuracy of predefined PI;
sqrt ( integer $scale = null ) : Decimal Returns the square root of this object
sub ( Decimal $b, integer $scale = null ) : Decimal Subtracts two BigNumber objects
tan ( integer $scale = null ) : Decimal Calculates the tangent of this method with the highest possible accuracy Note that accuracy is limited by the accuracy of predefined PI;

보호된 메소드들

메소드 설명
paramsValidation ( mixed $value, integer $scale ) Validates basic constructor's arguments

비공개 메소드들

메소드 설명
__clone ( ) Private clone method
__construct ( string $value, integer $scale ) Private constructor
compute2NRoot ( string $base, integer $index, integer $out_scale ) : string Auxiliar method. Computes $base^((1/2)^$index)
computeSquareIndex ( string $exponent_remaining, integer $actual_index, integer $exp_scale, integer $inner_scale ) : string Auxiliar method. It helps us to decompose the exponent into many summands.
countSignificativeDigits ( Decimal $val, Decimal $abs ) : integer Counts the number of significative digits of $val.
factorialSerie ( Decimal $x, Decimal $firstTerm, callable $generalTerm, $scale ) : Decimal Internal method used to compute sin, cos and exp
innerLog10 ( string $value, integer $in_scale, integer $out_scale ) : string Calculates the logarithm (in base 10) of $value
innerPowWithLittleExponent ( string $base, string $exponent, integer $exp_scale, integer $out_scale ) : string Returns $base^$exponent
innerRound ( string $value, integer $scale ) : string "Rounds" the decimal string to have at most $scale digits after the point
innerTruncate ( $scale, $ceil = true )
normalizeSign ( $sign ) : string
powerSerie ( Decimal $x, Decimal $firstTerm, $scale ) : Decimal Internal method used to compute arcsine and arcosine
removeTrailingZeros ( $strValue, &$scale )
simplePowerSerie ( Decimal $x, Decimal $firstTerm, $scale ) : Decimal Internal method used to compute arctan and arccotan

메소드 상세

__toString() 공개 메소드

public __toString ( ) : string
리턴 string

abs() 공개 메소드

Returns the absolute value (always a positive number)
public abs ( ) : Decimal
리턴 Decimal

add() 공개 메소드

Adds two Decimal objects
public add ( Decimal $b, integer $scale = null ) : Decimal
$b Decimal
$scale integer
리턴 Decimal

additiveInverse() 공개 메소드

Returns the element's additive inverse.
public additiveInverse ( ) : Decimal
리턴 Decimal

arccos() 공개 메소드

Calculates the arccosine of this with the highest possible accuracy
public arccos ( integer $scale = null ) : Decimal
$scale integer
리턴 Decimal

arccot() 공개 메소드

Calculates the arccotangente of this with the highest possible accuracy
public arccot ( integer $scale = null ) : Decimal
$scale integer
리턴 Decimal

arccsc() 공개 메소드

Calculates the arccosecant of this with the highest possible accuracy
public arccsc ( integer $scale = null ) : Decimal
$scale integer
리턴 Decimal

arcsec() 공개 메소드

Calculates the arcsecant of this with the highest possible accuracy
public arcsec ( integer $scale = null ) : Decimal
$scale integer
리턴 Decimal

arcsin() 공개 메소드

Calculates the arcsine of this with the highest possible accuracy
public arcsin ( integer $scale = null ) : Decimal
$scale integer
리턴 Decimal

arctan() 공개 메소드

Calculates the arctangente of this with the highest possible accuracy
public arctan ( integer $scale = null ) : Decimal
$scale integer
리턴 Decimal

asFloat() 공개 메소드

Return value as a float
public asFloat ( ) : float
리턴 float

asInteger() 공개 메소드

Return value as a integer
public asInteger ( ) : float
리턴 float

ceil() 공개 메소드

"Ceils" the Decimal to have at most $scale digits after the point
public ceil ( integer $scale ) : Decimal
$scale integer
리턴 Decimal

comp() 공개 메소드

$this > $b : returns 1 , $this < $b : returns -1 , $this == $b : returns 0
public comp ( Decimal $b, integer $scale = null ) : integer
$b Decimal
$scale integer
리턴 integer

cos() 공개 메소드

Calculates the cosine of this method with the highest possible accuracy Note that accuracy is limited by the accuracy of predefined PI;
public cos ( integer $scale = null ) : Decimal
$scale integer
리턴 Decimal cos($this)

cosec() 공개 메소드

Calculates the cosecant of this with the highest possible accuracy Note that accuracy is limited by the accuracy of predefined PI;
public cosec ( integer $scale = null ) : Decimal
$scale integer
리턴 Decimal

cotan() 공개 메소드

Calculates the cotangent of this method with the highest possible accuracy Note that accuracy is limited by the accuracy of predefined PI;
public cotan ( integer $scale = null ) : Decimal
$scale integer
리턴 Decimal cotan($this)

create() 공개 정적인 메소드

Decimal "constructor".
public static create ( mixed $value, integer $scale = null, boolean $removeZeros = false ) : Decimal
$value mixed
$scale integer
$removeZeros boolean If true then removes trailing zeros from the number representation
리턴 Decimal

div() 공개 메소드

Warning: div with $scale == 0 is not the same as integer division because it rounds the last digit in order to minimize the error.
public div ( Decimal $b, integer $scale = null ) : Decimal
$b Decimal
$scale integer
리턴 Decimal

equals() 공개 메소드

Equality comparison between this object and $b
public equals ( Decimal $b, integer $scale = null ) : boolean
$b Decimal
$scale integer
리턴 boolean

exp() 공개 메소드

Returns exp($this), said in other words: e^$this .
public exp ( integer $scale = null ) : Decimal
$scale integer
리턴 Decimal

floor() 공개 메소드

"Floors" the Decimal to have at most $scale digits after the point
public floor ( integer $scale ) : Decimal
$scale integer
리턴 Decimal

fromDecimal() 공개 정적인 메소드

Constructs a new Decimal object based on a previous one, but changing it's $scale property.
public static fromDecimal ( Decimal $decValue, integer $scale = null ) : Decimal
$decValue Decimal
$scale integer
리턴 Decimal

fromFloat() 공개 정적인 메소드

public static fromFloat ( float $fltValue, integer $scale = null, boolean $removeZeros = false ) : Decimal
$fltValue float
$scale integer
$removeZeros boolean If true then removes trailing zeros from the number representation
리턴 Decimal

fromInteger() 공개 정적인 메소드

public static fromInteger ( integer $intValue ) : Decimal
$intValue integer
리턴 Decimal

fromString() 공개 정적인 메소드

public static fromString ( string $strValue, integer $scale = null, boolean $removeZeros = false ) : Decimal
$strValue string
$scale integer
$removeZeros boolean If true then removes trailing zeros from the number representation
리턴 Decimal

getNegativeInfinite() 공개 정적인 메소드

Returns a "Negative Infinite" object
public static getNegativeInfinite ( ) : Decimal
리턴 Decimal

getPositiveInfinite() 공개 정적인 메소드

Returns a "Positive Infinite" object
public static getPositiveInfinite ( ) : Decimal
리턴 Decimal

hasSameSign() 공개 메소드

Indicates if the passed parameter has the same sign as the method's bound object.
public hasSameSign ( Decimal $b ) : boolean
$b Decimal
리턴 boolean

innerValue() 공개 메소드

Return the inner representation of the class use with caution
public innerValue ( ) : number
리턴 number

isInfinite() 공개 메소드

public isInfinite ( ) : boolean
리턴 boolean

isInteger() 공개 메소드

public isInteger ( ) : boolean
리턴 boolean

isNegative() 공개 메소드

public isNegative ( ) : boolean
리턴 boolean

isPositive() 공개 메소드

public isPositive ( ) : boolean
리턴 boolean

isZero() 공개 메소드

public isZero ( integer $scale = null ) : boolean
$scale integer
리턴 boolean

log10() 공개 메소드

Returns the object's logarithm in base 10
public log10 ( integer $scale = null ) : Decimal
$scale integer
리턴 Decimal

mod() 공개 메소드

Calculate modulo with a decimal
public mod ( Decimal $d, integer $scale = null )
$d Decimal
$scale integer

mul() 공개 메소드

Multiplies two BigNumber objects
public mul ( Decimal $b, integer $scale = null ) : Decimal
$b Decimal
$scale integer
리턴 Decimal

paramsValidation() 보호된 정적인 메소드

Validates basic constructor's arguments
protected static paramsValidation ( mixed $value, integer $scale )
$value mixed
$scale integer

pow() 공개 메소드

Powers this value to $b
public pow ( Decimal $b, integer $scale = null ) : Decimal
$b Decimal exponent
$scale integer
리턴 Decimal

round() 공개 메소드

"Rounds" the Decimal to have at most $scale digits after the point
public round ( integer $scale ) : Decimal
$scale integer
리턴 Decimal

sec() 공개 메소드

Calculates the secant of this with the highest possible accuracy Note that accuracy is limited by the accuracy of predefined PI;
public sec ( integer $scale = null ) : Decimal
$scale integer
리턴 Decimal

sin() 공개 메소드

Calculates the sine of this method with the highest possible accuracy Note that accuracy is limited by the accuracy of predefined PI;
public sin ( integer $scale = null ) : Decimal
$scale integer
리턴 Decimal sin($this)

sqrt() 공개 메소드

Returns the square root of this object
public sqrt ( integer $scale = null ) : Decimal
$scale integer
리턴 Decimal

sub() 공개 메소드

Subtracts two BigNumber objects
public sub ( Decimal $b, integer $scale = null ) : Decimal
$b Decimal
$scale integer
리턴 Decimal

tan() 공개 메소드

Calculates the tangent of this method with the highest possible accuracy Note that accuracy is limited by the accuracy of predefined PI;
public tan ( integer $scale = null ) : Decimal
$scale integer
리턴 Decimal tan($this)

프로퍼티 상세

$value 보호되어 있는 프로퍼티

Internal numeric value
protected string $value
리턴 string