![]() |
|
![]() |
| EvaluateSciFloat | LongRealToStr | RealToStr | RoundAndTrimSciFloat |
| StrToLongReal | StrToReal |
PROCEDURE StrToReal
(CONST Str : ARRAY OF CHAR;
VAR RealVal : REAL;
VAR Success : BOOLEAN);
PROCEDURE RealToStr
(CONST RealVal : REAL;
VAR Str : ARRAY OF CHAR;
CONST width : INTEGER;
CONST digits : INTEGER;
VAR Success : BOOLEAN);
(**
RealToStr - Convert Real to string, can be a fixed size.
This procedure converts a REAL into a string that represents the
number. There are two modes of using this routine. If the value of
width is equal to 0 then the value is converted to string in a free
format. If the value of width is greater than 0 the string is converted
in a fixed format.
Free format - If the value of width is 0 then this format is used. This
results in a string that is always left justified and only shows the sign
position if the number is negative. In this mode the only constraint to
converting is the size of the string that was passed in.
Fixed format - If the value of width is greater than 0 then this format is
used. In this mode the value is converted to a total length that equals
the size of width. NOTE - The value of width INCLUDES the sign character
if the number is negative (i.e. the value of -100.0 requires a width of 6).
If the value is positive it can completely fill the string (i.e. a width
of 6 can handle a positive value up to 9999.9).
If the string passed is shorter than width or if the converted value will
not fit within the length of the string then SageError #16
(SageErrs.ArrayTooSmall) is generated.
*)
PROCEDURE StrToLongReal
(CONST Str : ARRAY OF CHAR;
VAR RealVal : ModSys.FLOAT64;
VAR Success : BOOLEAN);
PROCEDURE LongRealToStr
(CONST RealVal : ModSys.FLOAT64;
VAR Str : ARRAY OF CHAR;
CONST width : INTEGER;
CONST digits : INTEGER;
VAR Success : BOOLEAN);
(**
LongRealToStr - Convert LongReal to string, can be a fixed size.
This procedure converts a LONGREAL into a string that represents the
number. There are two modes of using this routine. If the value of
width is equal to 0 then the value is converted to string in a free
format. If the value of width is greater than 0 the string is converted
in a fixed format.
Free format - If the value of width is 0 then this format is used. This
results in a string that is always left justified and only shows the sign
position if the number is negative. In this mode the only constraint to
converting is the size of the string that was passed in.
Fixed format - If the value of width is greater than 0 then this format is
used. In this mode the value is converted to a total length that equals
the size of width. NOTE - The value of width INCLUDES the sign character
if the number is negative (i.e. the value of -100.0 requires a width of 6).
If the value is positive it can completely fill the string (i.e. a width
of 6 can handle a positive value up to 9999.9).
If the string passed is shorter than width or if the converted value will
not fit within the length of the string then SageError #16
(SageErrs.ArrayTooSmall) is generated.
*)
PROCEDURE EvaluateSciFloat
(CONST Value : ARRAY OF CHAR;
VAR NumPreDecimal : CARDINAL;
VAR NumPostDecimal : CARDINAL;
VAR NumInExponent : CARDINAL;
VAR PreSignIsPositive : BOOLEAN;
VAR PostSignIsPositive : BOOLEAN;
VAR ePosition : CARDINAL;
VAR InvalidChars : BOOLEAN);
(**
EvaluateSciFloat - Parse the SciFloat to count sizes.
This procedure parses a supposedly SciFloat format alpha string
and returns the information about how it is composed. If
invalid characaters are encounted it reports that alos.
CALLING SEQUENCE -
EvaluateSciFloat (Value, NumPreDecimal, NumPostDecimal,
NumInExponent, PreSignIsPositive,
PostSignIsPositive, EPosition, InvalidChars)
ENTRY -
Value : ARRAY OF CHAR
The string containing the SciFloat format value.
EXIT -
NumPreDecimal : CARDINAL
The number of digits found before the decimal place. This does
NOT include the sign character.
NumPostDecimal : CARDINAL
The number of digits found after the decimal place and before the
'E' character. This does NOT include that character.
NumInExponent : CARDINAL
The number of digits found in the exponent position NOT including
the sign position.
PreSignIsPositive : BOOLEAN
True - The pre-decimal sign is positive.
False - The pre-decimal sign is negative.
PostSignIsPositive : BOOLEAN
True - The post-decimal sign is positive.
False - The post-decimal sign is negative.
EPosition : CARDINAL
The position in the string where the E character is found.
InvalidChars : BOOLEAN
TRUE - Invalid charaters for this format encounted.
FALSE - All characters valid in their respecitve positions.
*)
PROCEDURE RoundAndTrimSciFloat
(CONST NumDecimalDigits : CARDINAL;
VAR SciAlphaVal : ARRAY OF CHAR);
(**
RoundAndTrimSciFloat - Round and trim SciFloat value in the post decimal chars.
This procedure checks and rounds the post decimal positions of a SciFloat
format string. After trimming the string should be correctly rounded and
trimmed to only allow NumDecimalDigits of characters following the
decimal point and preceeding the 'E' character.
CALLING SEQUENCE -
RoundAndTrimSciFloat (NumDecimalDigits, SciAlphaVal)
ENTRY -
NumDecimalDigites : CARDINAL
The final allowable number of post decimal digits to retain.
EXIT -
SciAlphaVal : ARRAY OF CHAR
The string representing the correct rounded and trimmed value of the
floating point number.
*)
Send mail to
warren.merrill@inl.gov
with questions or comments about this web site.
Copyright © 1989-2006 Battelle Energy Alliance