Specifies a number in scientific notation using E notation format. This format allows for the representation of very large or small numbers to be easily readable in decimal form.

Syntax

The value m is followed by the letter E (or e), and the exponent (n), which can include an optional plus (+) or minus (-) sign.

m{E|e}[+|-]n
m
A real number. m is commonly represented as a decimal value.
n
The exponent which can have one or two digits.

Examples

Number representation using scientific notation format

The following examples show how to represent numbers in scientific notation format:

  • 1,000,000 is 1 × 106, which is written as 1E6 (or 1e6, 1E+6, 1e+6, 1.0E6).
  • 0.000123 is 1.23 × 10-4, which is written as 1.23e-4.
  • 123,123,123 is 1.23123123 × 108, which is written as 1.23e8 (if only two decimal places are allowed).

Expressions in ABL using scientific notation format

The following code contains expressions that use scientific notation format in ABL.

/* Variable initialization */
VAR INT64 solarSystemDiameterKm = 143e9.

/* Decimal array initialization - Note that scientific notation
   is optional for each individual value in the array */
VAR DECIMAL[] planetsDiameterkm = [12.742e+3, 4.8794e+3, 6779.0, 12.104e+3, 23766e-1].

/* Property declaration */
DEFINE PUBLIC PROPERTY solarSystemDiameterKm AS INT64 INITIAL 143e+9 
GET. SET.

/* Assignment */
AvogadroConstant = 6.02214076e+23.

/* Display a number using the FORMAT phrase */
DISPLAY AvogadroConstant FORMAT "9.99999E99".  //Displays 6.02214E23

/* Number constant passed as a parameter */
RUN MyProcedure(123.45e+2).

/* Math expression */
VAR INTEGER boxHeight = 500.
MESSAGE 
  "Box Height" boxHeight SKIP
  "Box Width" 1e3 SKIP
  "Area of Box" (boxHeight * 1e+3)
  VIEW-AS ALERT-BOX.

/* Number conversion functions */
VAR INTEGER MyInteger = INTEGER("123E+3").
VAR INT64 MyInt64 = INT64("1e+12").
VAR DECIMAL MyDecimal = DECIMAL("1.1e-5").

How to read JSON containing numbers in scientific notation format

The following example code shows how to read a JSON document that contains a number in scientific notation format:

USING Progress.Json.* FROM PROPATH.
USING Progress.Json.ObjectModel.* FROM PROPATH.

DEFINE VARIABLE myParser AS ObjectModelParser NO-UNDO.
DEFINE VARIABLE jsonObject AS JsonObject NO-UNDO.
DEFINE VARIABLE jsondata AS LONGCHAR NO-UNDO.

FIX-CODEPAGE(jsondata) = "utf-8".

jsondata = '~{ "somevalue": 123e+5 ~}'.

myParser = NEW ObjectModelParser( ).
jsonObject = CAST(myParser:Parse(jsondata), JsonObject).

MESSAGE jsonObject:GetDecimal("somevalue").

How to IMPORT data in scientific notation format

The following example code shows how to use the IMPORT statement to read a CSV file containing numbers in scientific notation format.

mydata.csv
1,1,1,1
1e1,1e1,1e1,1e1
100e-1,100e-1,100e-1,100e-1
100e-2,100e-2,100e-2,100e-2
100e-3,100e-3,100e-3,100e-3
Code to read mydata.csv
DEFINE TEMP-TABLE ttmydata
  FIELD mydatac AS CHARACTER
  FIELD mydatad AS DECIMAL
  FIELD mydatai AS INTEGER
  FIELD mydatai64 AS INT64.

INPUT FROM mydata.csv.
OUTPUT TO mydata.out.

REPEAT:
    CREATE ttmydata.
    IMPORT DELIMITER "," ttmydata.
    EXPORT DELIMITER "," ttmydata.
END.

OUTPUT CLOSE.
INPUT CLOSE.

Notes

  • The limits of existing INTEGER, INT64, or DECIMAL data types apply to numbers in scientific notation format. Decimal values have a limit of 50 digits including up to 10 digits to the right of the decimal point.
  • The maximum and minimum exponent value for reading a number in scientific notation form is +/- 99, including 0. For example, 0e0 is a valid number in scientific notation format (resulting in a 0).

    Once the value is read, the value is converted to internal decimal format (if possible), and is limited to 50 digits. So the maximum possible exponent value for writing a value in scientific notation format is 49 since one digit is always reserved for the real number portion.

  • The notation sign is optional. If not provided, the default is positive (+).
  • When the exponent is applied to a number, the result is rounded to fit the requested data type. For example, the limit of the DECIMAL data type is 10 digits to the right of the decimal, so any digits beyond that are rounded to fit within 10 decimal places.
  • Not all locations in the ABL syntax where a number is expected, accept numbers in scientific notation format. Some locations that accept only whole numbers do not accept scientific notation values. For example, the EXTENT size, an array subscript, and column or row numbers or x/y values in DISPLAY statements.
  • External sources that contain numbers in scientific notation format can be read and parsed in ABL. Data can be imported using the IMPORT statement. JSON or XML documents can also be read and parsed. For XML, this includes the READ-XML() method for temp-tables and datasets. For JSON, this includes the Progress.Json.ObjectModel.ObjectModelParser class and the READ-JSON() method.
  • The following general rules apply for the FORMAT phrase when expressing numbers in scientific notation:
    • The format may start with an optional sign place holder (+ or -) in the first position.
    • The optional sign must be followed by a placeholder digit (9) for the digit to the left of the decimal point. Zero suppression (>) is not allowed.
    • The digit place holder is optionally followed by the decimal separator.
    • The format may practically have up to 50 placeholders for digits of precision to the right of decimal. The digit placeholder value(s) may optionally be zero suppressed using one or more <.
    • The number format is always followed by an exponential number indicator E or e.
    • The exponential number indicator can optionally be followed by an exponential sign place holder to indicate either a negative or positive exponent is acceptable. If not provided, the default is positive (+).
    • The exponential sign place holder is a minus (-) or plus (+) sign. If a negative sign is used, the sign is suppressed if the exponent is positive. If a positive exponent sign is used, the sign is always displayed if the exponent is positive or negative.
    • The E (or e) notation must be followed by either one or two placeholder digits (9) to indicate the exponent.

    When displayed, the value must be capable of being displayed with the format specified, including the precision and scale of the value to the left of the exponent, with the number of digits allowed for the exponent, otherwise you get an error and the data cannot be formatted. In other words, values are not rounded in order to display it with the format specified.

    The following table shows examples of how a value is displayed given different formats. In general, the decimal is moved to the point where the whole number portion of the value is from 1 to 9. The decimal is moved either right or left as necessary to accomplish this. Any remaining values appear to the right of the decimal point with as many significant digits allowed by the format. The value may be rounded after coming up with the scientific notation format.

    Example value Format Value displayed Comments
    0.00000345 9.99E-9 3.45E-6 The format defines a single digit to the left of the decimal point, two to the right, and a single digit for the exponent (and a negative exponent is allowed).
    0.00000345 9.9E-9 3.5E-6 There is only one digit to the right of the decimal point, so the value is rounded.
    12345 9.99E9 1.23E4
    -10.0012345 9.99<<<<e-99 ERROR The number is negative but the format does not allow for it.
    -.00012345 -9.99<<<<e9 ERROR The exponent is negative but the format does not allow for a negative exponent.
    10029398483937984 9.9999999999E-99 1.0029398484E16 The value is rounded to 10 significant decimal places. There is no exponent sign since the format is negative but exponent is positive, so the sign is suppressed.
    10029300000000000 -9.9<<<<<<<<E-99 1.00293E16 The least significant digits are zero suppressed.
    10029300000000000 9.999999999E-99 1.002930000E16
    10029300000000000 9.999E+99 1.003E+16
    10029300000000000 9.999e+99 1.003e+16 The indicator (E or e) will be displayed exactly as specified in the format phrase.

    For a field that is enabled for Dynamic Data Masking, the format setting of a field is not honored when displaying the masked value.