Documentation

ConvertDecimal extends ConvertBase

Table of Contents

LARGEST_OCTAL_IN_DECIMAL 536870911
SMALLEST_OCTAL_IN_DECIMAL -536870912
LARGEST_BINARY_IN_DECIMAL 511
SMALLEST_BINARY_IN_DECIMAL -512
LARGEST_HEX_IN_DECIMAL 549755813887
SMALLEST_HEX_IN_DECIMAL -549755813888
toBinary() toBinary. string
toHex() toHex. string
hex32bit() string
toOctal() toOctal. string
validateDecimal() string
validateValue() string
validatePlaces() int|null
nbrConversionFormat() Formats a number base string value with leading zeroes. string

Constants

LARGEST_OCTAL_IN_DECIMAL

mixed $LARGEST_OCTAL_IN_DECIMAL = 536870911

SMALLEST_OCTAL_IN_DECIMAL

mixed $SMALLEST_OCTAL_IN_DECIMAL = -536870912

LARGEST_BINARY_IN_DECIMAL

mixed $LARGEST_BINARY_IN_DECIMAL = 511

SMALLEST_BINARY_IN_DECIMAL

mixed $SMALLEST_BINARY_IN_DECIMAL = -512

LARGEST_HEX_IN_DECIMAL

mixed $LARGEST_HEX_IN_DECIMAL = 549755813887

SMALLEST_HEX_IN_DECIMAL

mixed $SMALLEST_HEX_IN_DECIMAL = -549755813888

Methods

toBinary()

toBinary.

public static toBinary( $value : string [, $places : int = null ] ) : string

Return a decimal value as binary.

Excel Function: DEC2BIN(x[,places])

Parameters
$value : string

The decimal integer you want to convert. If number is negative, valid place values are ignored and DEC2BIN returns a 10-character (10-bit) binary number in which the most significant bit is the sign bit. The remaining 9 bits are magnitude bits. Negative numbers are represented using two's-complement notation. If number < -512 or if number > 511, DEC2BIN returns the #NUM! error value. If number is nonnumeric, DEC2BIN returns the #VALUE! error value. If DEC2BIN requires more than places characters, it returns the #NUM! error value.

$places : int = null

The number of characters to use. If places is omitted, DEC2BIN uses the minimum number of characters necessary. Places is useful for padding the return value with leading 0s (zeros). If places is not an integer, it is truncated. If places is nonnumeric, DEC2BIN returns the #VALUE! error value. If places is zero or negative, DEC2BIN returns the #NUM! error value.

Return values
string

toHex()

toHex.

public static toHex( $value : string [, $places : int = null ] ) : string

Return a decimal value as hex.

Excel Function: DEC2HEX(x[,places])

Parameters
$value : string

The decimal integer you want to convert. If number is negative, places is ignored and DEC2HEX returns a 10-character (40-bit) hexadecimal number in which the most significant bit is the sign bit. The remaining 39 bits are magnitude bits. Negative numbers are represented using two's-complement notation. If number < -549,755,813,888 or if number > 549,755,813,887, DEC2HEX returns the #NUM! error value. If number is nonnumeric, DEC2HEX returns the #VALUE! error value. If DEC2HEX requires more than places characters, it returns the

NUM! error value.

$places : int = null

The number of characters to use. If places is omitted, DEC2HEX uses the minimum number of characters necessary. Places is useful for padding the return value with leading 0s (zeros). If places is not an integer, it is truncated. If places is nonnumeric, DEC2HEX returns the #VALUE! error value. If places is zero or negative, DEC2HEX returns the #NUM! error value.

Return values
string

hex32bit()

public static hex32bit( $value : float , $hexstr : string [, $force : bool = false ] ) : string
Parameters
$value : float
$hexstr : string
$force : bool = false
Return values
string

toOctal()

toOctal.

public static toOctal( $value : string [, $places : int = null ] ) : string

Return an decimal value as octal.

Excel Function: DEC2OCT(x[,places])

Parameters
$value : string

The decimal integer you want to convert. If number is negative, places is ignored and DEC2OCT returns a 10-character (30-bit) octal number in which the most significant bit is the sign bit. The remaining 29 bits are magnitude bits. Negative numbers are represented using two's-complement notation. If number < -536,870,912 or if number > 536,870,911, DEC2OCT returns the #NUM! error value. If number is nonnumeric, DEC2OCT returns the #VALUE! error value. If DEC2OCT requires more than places characters, it returns the

NUM! error value.

$places : int = null

The number of characters to use. If places is omitted, DEC2OCT uses the minimum number of characters necessary. Places is useful for padding the return value with leading 0s (zeros). If places is not an integer, it is truncated. If places is nonnumeric, DEC2OCT returns the #VALUE! error value. If places is zero or negative, DEC2OCT returns the #NUM! error value.

Return values
string

validateDecimal()

protected static validateDecimal( $value : string ) : string
Parameters
$value : string
Return values
string

validateValue()

protected static validateValue( $value : mixed ) : string
Parameters
$value : mixed
Return values
string

validatePlaces()

protected static validatePlaces( [ $places : mixed = null ] ) : int|null
Parameters
$places : mixed = null
Return values
int|null

nbrConversionFormat()

Formats a number base string value with leading zeroes.

protected static nbrConversionFormat( $value : string , $places : int|null ) : string
Parameters
$value : string

The "number" to pad

$places : int|null

The length that we want to pad this value

Return values
string —

The padded "number"

Search results