The fnOctalUtil
namespace is a namespace that provides functions for converting octal integer strings to values of number
type. Functions of this namespace treat octal strings as strings of octal digits that represent bit values. Thus, octal strings are treated by this function as unsigned values. Use the fnBase8Util namespace's functions for unsigned/signed base 8 integer numbers.
To use this API alone by itself, include fnOctalUtil.js. Otherwise, include faiNumber-include-all.js.
This namespace API provides the function toNumber that can parse unsigned octal integer strings to values of number type.
This namespace API also provides functions for comparing unsigned octal integer strings pertain to the mathematical aspect. The compareAsNumber of this namespace API can compare strings by their actual number values when the strings are valid octal integer strings that can be parsed to number values.
Strings can also be compared using the numberOrSmaller method, of which compares the strings bases on their content reference to number values.
- Since:
- 1.0.0.f
- Source:
Members
(static) fileversion
- Source:
Methods
(static) compareAsNumber(firstNumber, secondNumber) → {string|undefined}
Compare two strings as unsigned octal integer strings by parsing them to type number values first.
Take note that comparing strings with values larger than Number.MAX_SAFE_INTEGER will yield an undefined value.
This function does not throw errors. However, the toNumber function uses by this function throws error.
- Since:
- 1.0.0.f
- Source:
- See:
Parameters: | ||
---|---|---|
Name | Type | Description |
firstNumber | string | A string to be compared to the string secondNumber . |
secondNumber | string | A string to be compared to the string firstNumber . |
Returns: | |
---|---|
Type | Description |
string | A value of 1 if the firstNumber string is larger than the secondNumber string, 0 if they are both equal, or -1 if the firstNumber string is smaller than the secondNumber string. |
undefined | If parsing either one of the input strings yielded an undefined value, an undefined value is returned. |
(static) numberOrSmaller(firstNumber, secondNumber) → {number}
Compare two strings bases on the content of the strings reference to type number. If the strings are valid unsigned octal integer strings that can be parsed to type number values then they will be compared base on their number values. Otherwise, the strings will be compared base on the priority ranking order below.
Take note that this method treats strings with values larger than Number.MAX_SAFE_INTEGER as undefined.
This function does not throw errors. However, the toNumber ultilizes by this function throws error.
Priority order ranking: (lo - hi)
0 - Undefined(NaN/Not a safe value)
1 - Empty strings
2 - Valid number values in range of MIN_SAFE_INTEGER and MAX_SAFE_INTEGER
- Since:
- 1.0.0.f
- Source:
- See:
Parameters: | ||
---|---|---|
Name | Type | Description |
firstNumber | string | A string to be compared to the string secondNumber . |
secondNumber | string | A string to be compared to the string firstNumber . |
Returns: | |
---|---|
Type | Description |
number | A value of 1 if the firstNumber string is larger than the secondNumber string, 0 if they are both equal, or -1 if the firstNumber string is smaller than the secondNumber string. |
(static) toNumber(input) → {number|undefined}
- Since:
- 1.0.0.f
- Source:
Parameters: | ||
---|---|---|
Name | Type | Description |
input | string | A string to be parsed as an unsigned octal integer number to a value of type number. |
Throws: | |
---|---|
Type | Description |
string | "Not a string" if the input is not of string type. |
Returns: | |
---|---|
Type | Description |
number | A value of type number of the input string if the input string is a valid unsigned octal integer string. |
undefined | A value of undefined is returned if the Parsing a value that is larger than the value of Number.MAX_SAFE_INTEGER(9007199254740991) will yield an undefined value. |