after posting the thread http://natural.forums.softwareag.com/viewtopic.php?t=266 and thinking about the answers I had an idea of an enhancement request: I would like to have packed and unpacked floating numbers. Let me explain by example:
DEFINE DATA LOCAL 1 NUM (N10) FLOATING 1 PACK (P15) FLOATING END-DEFINE
This will reserve 10 rsp. 15 significant digits and Natural keeps track of the position of the decimal point. Each number in the range of (N1,9) to (N10) / (P1,14) to P(15) can be placed in this fields.
The format can be in the range of 2 to 15 digits.
When used in an arithmetic expression, the intermediate results are of format (N15,14) / (P15,14) and then assigned to the resulting field either in the exactly defined format or, for the new “floating”, left justifed with possible truncation (or rounding) of decimal digits.
When exporting (PRINT/DISPLAY/WRITE/ WRITE WORK) these numbers, they are converted to readable strings consisting of sign (optional), digits before decimal point, decimal character (according to DC), digits after decimal point. The occupied length is the number of digits plus 2 bytes for sign and decimal character. The resulting string is by default left justified and padded with blanks or zeros.
This also applies to format conversions to alphanumeric strings (MOVE floating-var TO ALPHA/COMPRESS floating-var TO…)
When importing (INPUT/READ WORK/SEPARATE) these numbers, they are evaluated implicitely by the VAL function (with possible truncation of decimal digits!).
What do you think about this?