This module, fnBinaryUtil
contains procedures for working with binary strings and int32 data type.
Note
This module treats binary strings as bit values represented by binary digits and not real numbers. Thus, binary strings parse by this module will be converted to int32 values as if they are real bit values represented by binary digits.
Note
Unless stated otherwise, procedures of this module are pure procedures.
Uses
Functions
public pure function binaryInt32OrSmaller(firstString, secondString) result(int32Out)
- Author
- Khang Hoang Nguyen
- Since
- 1.0.0.f
Compare two strings bases on the content of the strings reference to int32 values. If the strings are valid binary strings that can be parsed to int32 values then they will be compared base on their int32 values. Otherwise, the strings will be compared base on the priority ranking order below.
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)
Subroutines
public pure subroutine binaryToInt32(input, output, error, startpos, endpos)
- Author
- Khang Hoang Nguyen
- Since
- 1.0.0.f
Parse the input
string as bits represented by binary digits to an int32 value.
Arguments
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | input | A string to be parsed as a binary string to an int32 value. | ||
integer(kind=k_int32), | intent(out) | :: | output | An int32 value of the | ||
logical, | intent(out) | :: | error | A value of | ||
integer(kind=k_int32), | intent(in), | optional | :: | startpos | An int32 value of the position(inclusive) of where to start parsing. | |
integer(kind=k_int32), | intent(in), | optional | :: | endpos | An int32 value of the position(inclusive) of where to end parsing. |
public pure subroutine binaryToInt32TrueError(input, output, error, startpos, endpos)
- Author
- Khang Hoang Nguyen
- Since
- 1.0.0.f
Parse the input
string as bits represented by binary digits to an int32 value.
Arguments
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | input | A string to be parsed as a binary string to an int32 value. | ||
integer(kind=k_int32), | intent(out) | :: | output | An int32 value of the | ||
integer(kind=k_int32), | intent(out) | :: | error | An int32 value of 0 on successful parse cases or a true error code on unsuccessful parse cases. | ||
integer(kind=k_int32), | intent(in), | optional | :: | startpos | An int32 value of the position(inclusive) of where to start parsing. | |
integer(kind=k_int32), | intent(in), | optional | :: | endpos | An int32 value of the position(inclusive) of where to end parsing. |
public pure subroutine binaryCompareAsInt32(firstString, secondString, output, error)
- Author
- Khang Hoang Nguyen
- Since
- 1.0.0.f
Compare two strings as binary strings by parsing them to int32 values first.
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 | ||
logical, | intent(out) | :: | error | A value of |