fnNumberStringUtil Module

This module, fnNumberStringUtil 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 pure function isInteger(input) result(lOut)
Author
Khang Hoang Nguyen
Since
1.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 pure function isUnsignedInteger(input) result(lOut)
Author
Khang Hoang Nguyen
Since
1.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 pure function isBinary(input) result(lOut)
Author
Khang Hoang Nguyen
Since
1.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 pure function isUnsignedBinary(input) result(lOut)
Author
Khang Hoang Nguyen
Since
1.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 pure function isOctal(input) result(lOut)
Author
Khang Hoang Nguyen
Since
1.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 pure function isUnsignedOctal(input) result(lOut)
Author
Khang Hoang Nguyen
Since
1.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 pure function isHex(input) result(lOut)
Author
Khang Hoang Nguyen
Since
1.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 pure function isUnsignedHex(input) result(lOut)
Author
Khang Hoang Nguyen
Since
1.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 pure function assumeCompare(firstString, secondString) result(int32Out)
Author
Khang Hoang Nguyen
Since
1.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 pure function assumeCompareAllBase(firstString, secondString) result(int32Out)
Author
Khang Hoang Nguyen
Since
1.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)


Subroutines

public pure subroutine isBase(input, base, output, error)
Author
Khang Hoang Nguyen
Since
1.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.

logical, intent(out) :: error

A value of .TRUE. on error. Otherwise, a value of .FALSE..

public pure subroutine isUnsignedBase(input, base, output, error)
Author
Khang Hoang Nguyen
Since
1.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.

logical, intent(out) :: error

A value of .TRUE. on error. Otherwise, a value of .FALSE..

public pure subroutine assumeIsOdd(input, output, error)
Author
Khang Hoang Nguyen
Since
1.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..

logical, intent(out) :: error

A value of .TRUE. on error. Otherwise, a value of .FALSE..

public pure subroutine assumeIsEven(input, output, error)
Author
Khang Hoang Nguyen
Since
1.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..

logical, intent(out) :: error

A value of .TRUE. on error. Otherwise, a value of .FALSE..

public pure subroutine fnStringCompare(firstString, secondString, output, error)
Author
Khang Hoang Nguyen
Since
1.0.0.f

Compare two strings as decimal integers. This subroutine 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.

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

An int32 value of 0 if no error was encountered. Otherwise, a true error code.

public pure subroutine fnStringCompareAsBase(firstString, secondString, base, output, error)
Author
Khang Hoang Nguyen
Since
1.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.

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

An int32 value of 0 if no error was encountered. Otherwise, a true error code.