Namespace: fnOctalUtil

fnOctalUtil

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
Author:
  • Khang Hoang Nguyen
Source:

Members

(static) fileversion

File version number.
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:
NameTypeDescription
firstNumberstringA string to be compared to the string secondNumber.
secondNumberstringA string to be compared to the string firstNumber.
Returns:
TypeDescription
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:
NameTypeDescription
firstNumberstringA string to be compared to the string secondNumber.
secondNumberstringA string to be compared to the string firstNumber.
Returns:
TypeDescription
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}

Parse the input string as a string of unsigned octal integer to a value of type number.
Since:
  • 1.0.0.f
Source:
Parameters:
NameTypeDescription
inputstringA string to be parsed as an unsigned octal integer number to a value of type number.
Throws:
TypeDescription
string
"Not a string" if the input is not of string type.
Returns:
TypeDescription
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 input string is not a valid unsigned octal integer string. Undefined is also returned where the input string is empty.

Parsing a value that is larger than the value of Number.MAX_SAFE_INTEGER(9007199254740991) will yield an undefined value.