fniNumberStringUtil Module

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.


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.

Read more…

Arguments

Type IntentOptional AttributesName
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.

Read more…

Arguments

Type IntentOptional AttributesName
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.

Read more…

Arguments

Type IntentOptional AttributesName
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.

Read more…

Arguments

Type IntentOptional AttributesName
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.

Read more…

Arguments

Type IntentOptional AttributesName
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.

Read more…

Arguments

Type IntentOptional AttributesName
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.

Read more…

Arguments

Type IntentOptional AttributesName
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.

Read more…

Arguments

Type IntentOptional AttributesName
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.

Read more…

Arguments

Type IntentOptional AttributesName
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

.TRUE. if the input string is a valid signed integer string of the defined numbering system. .FALSE. if the input string is empty(only spaces), 0 length, or is not a valid signed integer string of the defined numbering system.

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.

Read more…

Arguments

Type IntentOptional AttributesName
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

.TRUE. if the input string is a valid unsigned integer string of the defined numbering system. .FALSE. if the input string is empty(only spaces), 0 length, or is not a valid unsigned integer string of the defined numbering system.

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.

Read more…

Arguments

Type IntentOptional AttributesName
character(len=*), intent(in) :: input

A string.

logical, intent(out) :: output

.TRUE. if the rightmost character(exclude trailing spaces) is an odd value, or otherwise, .FALSE..

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.

Read more…

Arguments

Type IntentOptional AttributesName
character(len=*), intent(in) :: input

A string.

logical, intent(out) :: output

.TRUE. if the rightmost character(exclude trailing spaces) is an even value, or otherwise, .FALSE..

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.

Read more…

Arguments

Type IntentOptional AttributesName
character(len=*), intent(in) :: firstString

A string to be compared to the string secondString.

character(len=*), intent(in) :: secondString

A string to be compared to the string firstString.

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.

Read more…

Arguments

Type IntentOptional AttributesName
character(len=*), intent(in) :: firstString

A string to be compared to the string secondString.

character(len=*), intent(in) :: secondString

A string to be compared to the string firstString.

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.

Read more…

Arguments

Type IntentOptional AttributesName
character(len=*), intent(in) :: firstString

A string to be compared to the string secondString.

character(len=*), intent(in) :: secondString

A string to be compared to the string firstString.

integer(kind=k_int32), intent(out) :: output

An int32 value of 1 if the firstString is larger than the secondString, 0 if they are both equal, or -1 if the firstString is smaller than the secondString. This value may not be a correct value if an error has occurred during the comparison process.

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.

Read more…

Arguments

Type IntentOptional AttributesName
character(len=*), intent(in) :: firstString

A string to be compared to the string secondString.

character(len=*), intent(in) :: secondString

A string to be compared to the string firstString.

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 firstString is larger than the secondString, 0 if they are both equal, or -1 if the firstString is smaller than the secondString. This value may not be a correct value if an error has occurred during the comparison process.

Return Value integer(kind=k_int32)