A PHP representation of the CQL decimal datatype

The actual value of a decimal is $value * pow(10, $scale * -1)

Implements

Methods

__construct

( string $value )

Creates a decimal from a given decimal string:

<?php
$decimal = new Dse\Decimal("1313123123.234234234234234234123");

$this->assertEquals(21, $decimal->scale());
$this->assertEquals("1313123123234234234234234234123", $decimal->value());
Parameters:
Name Type Details
$value string

Any decimal string

string

__toString

( )

String representation of this decimal.

Returns:
Type Details
string

Dse\Decimal value

Dse\Type

type

( )

The type of this decimal.

Returns:
Type Details
Dse\Type
string

value

( )

Dse\Numeric value of this decimal as string.

Returns:
Type Details
string

Dse\Numeric value

int

scale

( )

Scale of this decimal as int.

Returns:
Type Details
int

Scale

Dse\Numeric

add

( Dse\Numeric $num )
Parameters:
Name Type Details
$num Dse\Numeric

a number to add to this one

Returns:
Type Details
Dse\Numeric

sum

Dse\Numeric

sub

( Dse\Numeric $num )
Parameters:
Name Type Details
$num Dse\Numeric

a number to subtract from this one

Returns:
Type Details
Dse\Numeric

difference

Dse\Numeric

mul

( Dse\Numeric $num )
Parameters:
Name Type Details
$num Dse\Numeric

a number to multiply this one by

Returns:
Type Details
Dse\Numeric

product

Dse\Numeric

div

( Dse\Numeric $num )
Parameters:
Name Type Details
$num Dse\Numeric

a number to divide this one by

Returns:
Type Details
Dse\Numeric

quotient

Dse\Numeric

mod

( Dse\Numeric $num )
Parameters:
Name Type Details
$num Dse\Numeric

a number to divide this one by

Returns:
Type Details
Dse\Numeric

remainder

Dse\Numeric

abs

( )
Returns:
Type Details
Dse\Numeric

absolute value

Dse\Numeric

neg

( )
Returns:
Type Details
Dse\Numeric

negative value

Dse\Numeric

sqrt

( )
Returns:
Type Details
Dse\Numeric

square root

int

toInt

( )
Returns:
Type Details
int

this number as int

float

toDouble

( )
Returns:
Type Details
float

this number as float