ConvertDecimal extends ConvertBase
Table of Contents
| toBinary() | toBinary. | string |
|---|---|---|
| toHex() | toHex. | string |
| toOctal() | toOctal. | string |
| validateDecimal() | string | |
| validateValue() | string | |
| validatePlaces() | int|null | |
| nbrConversionFormat() | Formats a number base string value with leading zeroes. | string |
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
stringtoHex()
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
stringtoOctal()
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
stringvalidateDecimal()
protected
static validateDecimal(
$value :
string
)
: string
Parameters
- $value : string
Return values
stringvalidateValue()
protected
static validateValue(
$value :
mixed
[, $gnumericCheck :
bool
= false ]
)
: string
Parameters
- $value : mixed
- $gnumericCheck : bool = false
Return values
stringvalidatePlaces()
protected
static validatePlaces(
[ $places :
mixed
= null ]
)
: int|null
Parameters
- $places : mixed = null
Return values
int|nullnbrConversionFormat()
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"