ISDIGIT
Determines whether the input character is a digit (0-9).
ISPM
Determines whether the input character is a + or - sign.
ISHEX
Determines whether the input character is a valid hexadecimal digit
ISREAL
Determines whether the input string is a number. If it is, it will also return its value.
In decimal mode, the input string is a number if it satisfies all of these criteria:
1. The first non-blank character is a digit, +, -, or decimal point (.). 2. It contains, at most, one decimal point. 3. It contains, at most, one occurrence of E. 4. Any decimal point occurs before any E. 5. The E may be followed by an optional + or -. 6. A letter E must be followed by at least one digit (after the optional + or -). 7. + or - may only be the first non-blank character, or the character immediately following E. 8. It contains no other characters besides: digits, +, -, decimal point (.), and E.
If not in decimal mode, the input string is a number if it satisfies these criteria:
1. BIN: digits 0 and 1 only 2. OCT: digits 0-7 only 3. HEX: digits 0-9 and A-F only
Uses functions: ISDIGIT, ISPM, ISHEX
ISCOMPLEX
Determines whether the input string is a complex number. If it is, it will also return its value. A complex number consists of two real numbers separated by a comma (no space). For example: 2.0,5.0E2
In decimal mode, the input string is a number if it satisfies all of these criteria:
1. The first non-blank character is a digit, +, -, or decimal point (.). 2. It contains, at most, one decimal point. 3. It contains, at most, one occurrence of E. 4. Any decimal point occurs before any E. 5. The E may be followed by an optional + or -. 6. A letter E must be followed by at least one digit (after the optional + or -). 7. + or - may only be the first non-blank character, or the character immediately following E. 8. It contains no other characters besides: digits, +, -, decimal point (.), and E.
If not in decimal mode, the input string is a number if it satisfies these criteria:
1. BIN: digits 0 and 1 only 2. OCT: digits 0-7 only 3. HEX: digits 0-9 and A-F only
Uses functions: ISDIGIT, ISPM, ISHEX
ISRATIONAL
Determines whether the input string is a rational number. If it is, it will also return its value. A rational number consists of two integers separated by a slash (no space). For example: 2/5
In decimal mode, the input string is a number if it satisfies all of these criteria:
1. The first non-blank character is a digit, +, or -. 2. It contains no other characters besides: digits, +, and -.
If not in decimal mode, the input string is a number if it satisfies these criteria:
1. BIN: digits 0 and 1 only 2. OCT: digits 0-7 only 3. HEX: digits 0-9 and A-F only
Uses functions: ISDIGIT, ISPM, ISHEX
SWITCH_RAT_TO_REAL
ISFRAC
Returns .TRUE. if X has a fractional part (i.e. if X is not an integer)
ISINT
Returns .TRUE. if X has no fractional part (i.e. if X is an integer)
FRAC_TO_MIXED
Convert a fraction from improper format to mixed format.
MATHEMATICAL FUNCTIONS
GCD
Greatest common divisor. Find the greatest common divisor of two integers using Euclid's algorithm.
LCM
Least common multiple. Find the least common multiple of two integers.
RATNORM
Normalize a rational number Check for a denominator or numerator of 0; make the denominator positive; and reduce the fraction.
RADD
Add two rational numbers.
RSUB
Subtract two rational numbers.
RMUL
Multiply two rational numbers.
RDIV
Multiply two rational numbers.
DEC_TO_FRAC
Converts a decimal number to a fraction. Algorithm from "An Atlas of Functions" by Spanier and Oldham, Springer-Verlag, 1987, pp. 665-667.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character, | intent(in) | :: | CH |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character, | intent(in) | :: | CH |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character, | intent(in) | :: | CH |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | STR | |||
real(kind=wp), | intent(out) | :: | X |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | STR | |||
complex(kind=wp), | intent(out) | :: | X |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | STR | |||
integer, | intent(out) | :: | NUM | |||
integer, | intent(out) | :: | DEN |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | X |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | X |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | A | |||
integer, | intent(in) | :: | B |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | A | |||
integer, | intent(in) | :: | B |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | AN | |||
integer, | intent(in) | :: | AD | |||
integer, | intent(out) | :: | A1 | |||
integer, | intent(out) | :: | A2 | |||
integer, | intent(out) | :: | A3 |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(inout) | :: | NUM | |||
integer, | intent(inout) | :: | DEN |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | N1 | |||
integer, | intent(in) | :: | D1 | |||
integer, | intent(in) | :: | N2 | |||
integer, | intent(in) | :: | D2 | |||
integer, | intent(out) | :: | NR | |||
integer, | intent(out) | :: | DR |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | N1 | |||
integer, | intent(in) | :: | D1 | |||
integer, | intent(in) | :: | N2 | |||
integer, | intent(in) | :: | D2 | |||
integer, | intent(out) | :: | NR | |||
integer, | intent(out) | :: | DR |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | N1 | |||
integer, | intent(in) | :: | D1 | |||
integer, | intent(in) | :: | N2 | |||
integer, | intent(in) | :: | D2 | |||
integer, | intent(out) | :: | NR | |||
integer, | intent(out) | :: | DR |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | N1 | |||
integer, | intent(in) | :: | D1 | |||
integer, | intent(in) | :: | N2 | |||
integer, | intent(in) | :: | D2 | |||
integer, | intent(out) | :: | NR | |||
integer, | intent(out) | :: | DR |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | X | |||
integer, | intent(out) | :: | NUM | |||
integer, | intent(out) | :: | DEN | |||
real(kind=wp), | intent(in), | optional | :: | TOL |