This module, fniNumberStringUtil
contains procedures for validating and comparing numerical strings.
For comparing numerical strings, this module has some very powerful and flexible procedures that can compare numerical strings of unlimited length. These procedures, assumeCompare, assumeCompareAllBase, fnStringCompare, and fnStringCompareAsBase can compare numerical strings without needing to parse the strings to values of a data type. Under the best case scenario, the mentioned procedures can be extremely fast.
Note
Procedures of this module may not be pure procedures.
Uses
Functions
public function isInteger(input)
- Author
- Khang Hoang Nguyen
- Since
- 1n.0.0.f
Check if the input
string is a valid signed decimal integer string.
Arguments
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | input | A string. |
Return Value logical
public function isUnsignedInteger(input)
- Author
- Khang Hoang Nguyen
- Since
- 1n.0.0.f
Check if the input
string is a valid unsigned decimal integer string.
Arguments
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | input | A string. |
Return Value logical
public function isBinary(input)
- Author
- Khang Hoang Nguyen
- Since
- 1n.0.0.f
Check if the input
string is a valid signed binary integer string.
Arguments
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | input | A string. |
Return Value logical
public function isUnsignedBinary(input)
- Author
- Khang Hoang Nguyen
- Since
- 1n.0.0.f
Check if the input
string is a valid unsigned binary integer string.
Arguments
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | input | A string. |
Return Value logical
public function isOctal(input)
- Author
- Khang Hoang Nguyen
- Since
- 1n.0.0.f
Check if the input
string is a valid signed octal integer string.
Arguments
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | input | A string. |
Return Value logical
public function isUnsignedOctal(input)
- Author
- Khang Hoang Nguyen
- Since
- 1n.0.0.f
Check if the input
string is a valid unsigned octal integer string.
Arguments
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | input | A string. |
Return Value logical
public function isHex(input)
- Author
- Khang Hoang Nguyen
- Since
- 1n.0.0.f
Check if the input
string is a valid signed hexadecimal integer string.
Arguments
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | input | A string. |
Return Value logical
public function isUnsignedHex(input)
- Author
- Khang Hoang Nguyen
- Since
- 1n.0.0.f
Check if the input
string is a valid unsigned hexadecimal integer string.
Arguments
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | input | A string. |
Return Value logical
public function isBase(input, base, output) result(error)
- Author
- Khang Hoang Nguyen
- Since
- 1n.0.0.f
Check if the input
string is a valid signed integer string of the numbering system with the radix that is defined by the value of the argument base
.
Arguments
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | input | A string. | ||
integer(kind=k_int32), | intent(in) | :: | base | An int32 value that define the radix. | ||
logical, | intent(out) | :: | output |
|
Return Value logical
public function isUnsignedBase(input, base, output) result(error)
- Author
- Khang Hoang Nguyen
- Since
- 1n.0.0.f
Check if the input
string is a valid unsigned integer string of the numbering system with the radix that is defined by the value of the argument base
.
Arguments
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | input | A string. | ||
integer(kind=k_int32), | intent(in) | :: | base | An int32 value that define the radix. | ||
logical, | intent(out) | :: | output |
|
Return Value logical
public function assumeIsOdd(input, output) result(error)
- Author
- Khang Hoang Nguyen
- Since
- 1n.0.0.f
Check the input
string to see if it holds an odd value with the assumption that the string is a valid decimal integer string.
Arguments
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | input | A string. | ||
logical, | intent(out) | :: | output |
|
Return Value logical
public function assumeIsEven(input, output) result(error)
- Author
- Khang Hoang Nguyen
- Since
- 1n.0.0.f
Check the input
string to see if it holds an even value with the assumption that the string is a valid decimal integer string.
Arguments
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | input | A string. | ||
logical, | intent(out) | :: | output |
|
Return Value logical
public function assumeCompare(firstString, secondString)
- Author
- Khang Hoang Nguyen
- Since
- 1n.0.0.f
Compare two strings with the assumption that both strings are valid decimal integers.
Arguments
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | firstString | A string to be compared to the string | ||
character(len=*), | intent(in) | :: | secondString | A string to be compared to the string |
Return Value integer(kind=k_int32)
public function assumeCompareAllBase(firstString, secondString)
- Author
- Khang Hoang Nguyen
- Since
- 1n.0.0.f
Compare two strings with the assumption that both strings are valid integers of any radix between 2 and 36.
Arguments
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | firstString | A string to be compared to the string | ||
character(len=*), | intent(in) | :: | secondString | A string to be compared to the string |
Return Value integer(kind=k_int32)
public function fnStringCompare(firstString, secondString, output) result(error)
- Author
- Khang Hoang Nguyen
- Since
- 1n.0.0.f
Compare two strings as decimal integers. This function evaluates both, negative and positive values. There isn't a maximum length for the strings. Nonetheless, the strings can't be empty.
Arguments
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | firstString | A string to be compared to the string | ||
character(len=*), | intent(in) | :: | secondString | A string to be compared to the string | ||
integer(kind=k_int32), | intent(out) | :: | output | An int32 value of 1 if the |
Return Value integer(kind=k_int32)
public function fnStringCompareAsBase(firstString, secondString, base, output) result(error)
- Author
- Khang Hoang Nguyen
- Since
- 1n.0.0.f
Compare two strings as integer strings of a numbering system with the radix that is defined by the value of the argument base
. There isn't a maximum length for the strings. Nonetheless, the strings can't be empty.
Arguments
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | firstString | A string to be compared to the string | ||
character(len=*), | intent(in) | :: | secondString | A string to be compared to the string | ||
integer(kind=k_int32), | intent(in) | :: | base | An int32 value that define the radix. | ||
integer(kind=k_int32), | intent(out) | :: | output | An int32 value of 1 if the |