Skip to content

Helper Methods

Jordan LeDoux edited this page Jan 16, 2017 · 4 revisions

Helpers for NumberInterface

The following helper methods are available on any class that implements NumberInterface

getValue(): string

Returns the current value as a string. Note: This will return the current value in whatever the current base is.

getPrecision(): int

Returns the precision setting of the object.

getBase(): int

Returns the base of the current value.

isNegative(): bool

Returns true if the number is less than 0, false otherwise. Note: Zero is not considered negative.

isPositive(): bool

Returns true if the number is greater than 0, false otherwise. Note: Zero is not considered positive.

isEqual(int|float|numeric|NumberInterface $value): bool

Returns true if the object and value are equal to each other, false otherwise. Note: Does not round or truncate based on precision prior to comparison.

isGreaterThan(int|float|numeric|NumberInterface $value): bool

Returns true if the object is greater than the value argument, false otherwise. Note: Does not round or truncate based on precision prior to comparison.

isGreaterThanOrEqualTo(int|float|numeric|NumberInterface $value): bool

Returns true if the object is greater than or equal to the value argument, false otherwise. Note: Does not round or truncate based on precision prior to comparison.

isLessThan(int|float|numeric|NumberInterface $value): bool

Returns true if the object is less than the value argument, false otherwise. Note: Does not round or truncate based on precision prior to comparison.

isLessThanOrEqualTo(int|float|numeric|NumberInterface $value): bool

Returns true if the object is less than or equal to the value argument, false otherwise. Note: Does not round or truncate based on precision prior to comparison.

compare(int|float|numeric|NumberInterface $value): bool

Returns 1 if the object is greater than the value argument, 0 if they are equal, and -1 if the object is less than the value argument. Note: Does not round or truncate based on precision prior to comparison.

abs(): self

Applies the absolute value function to the current object. Note: For Mutable objects, this method will alter the object.

absValue(): string

Returns the absolute value of the current object as a string without altering the object.

convertToBase(int $base): self

Changes the base of the current object and converts its value to that base.