Number
class Number (View source)
Provides helper methods for manipulating numbers.
Methods
Verifies that a number is a multiple of a given step.
Generates a sorting code from an integer.
Decodes a sorting code back to an integer.
Details
static bool
validStep(float $value, float $step, float $offset = 0.0)
Verifies that a number is a multiple of a given step.
The implementation assumes it is dealing with IEEE 754 double precision floating point numbers that are used by PHP on most systems.
This is based on the number/range verification methods of webkit.
static string
intToAlphadecimal(int $i = 0)
Generates a sorting code from an integer.
Consists of a leading character indicating length, followed by N digits with a numerical value in base 36 (alphadecimal). These codes can be sorted as strings without altering numerical order.
It goes: 00, 01, 02, ..., 0y, 0z, 110, 111, ... , 1zy, 1zz, 2100, 2101, ..., 2zzy, 2zzz, 31000, 31001, ...
static int
alphadecimalToInt(string $string = '00')
Decodes a sorting code back to an integer.