Documentation

ConvertBinary extends ConvertBase

Table of Contents

toDecimal() toDecimal. string
toHex() toHex. string
toOctal() toOctal. string
validateBinary() string
validateValue() string
validatePlaces() int|null
nbrConversionFormat() Formats a number base string value with leading zeroes. string

Methods

toDecimal()

toDecimal.

public static toDecimal( $value : string ) : string

Return a binary value as decimal.

Excel Function: BIN2DEC(x)

Parameters
$value : string

The binary number (as a string) that you want to convert. The number cannot contain more than 10 characters (10 bits). The most significant bit of number is the sign bit. The remaining 9 bits are magnitude bits. Negative numbers are represented using two's-complement notation. If number is not a valid binary number, or if number contains more than 10 characters (10 bits), BIN2DEC returns the #NUM! error value.

Return values
string

toHex()

toHex.

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

Return a binary value as hex.

Excel Function: BIN2HEX(x[,places])

Parameters
$value : string

The binary number (as a string) that you want to convert. The number cannot contain more than 10 characters (10 bits). The most significant bit of number is the sign bit. The remaining 9 bits are magnitude bits. Negative numbers are represented using two's-complement notation. If number is not a valid binary number, or if number contains more than 10 characters (10 bits), BIN2HEX returns the #NUM! error value.

$places : int = null

The number of characters to use. If places is omitted, BIN2HEX 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, BIN2HEX returns the #VALUE! error value. If places is negative, BIN2HEX returns the #NUM! error value.

Return values
string

toOctal()

toOctal.

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

Return a binary value as octal.

Excel Function: BIN2OCT(x[,places])

Parameters
$value : string

The binary number (as a string) that you want to convert. The number cannot contain more than 10 characters (10 bits). The most significant bit of number is the sign bit. The remaining 9 bits are magnitude bits. Negative numbers are represented using two's-complement notation. If number is not a valid binary number, or if number contains more than 10 characters (10 bits), BIN2OCT returns the #NUM! error value.

$places : int = null

The number of characters to use. If places is omitted, BIN2OCT 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, BIN2OCT returns the #VALUE! error value. If places is negative, BIN2OCT returns the #NUM! error value.

Return values
string

validateBinary()

protected static validateBinary( $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