Question about X12 decimal numbers: leading zero suppression and exponent notation
siddharth.sarda last edited by
In the X12.6 specification, section 22.214.171.124 Decimal Numbers states, "Leading zeros shall be suppressed unless necessary to satisfy a minimum length requirement." I have a few questions about how this instruction is applied in practice:
Given an R element with a minimum length of 1, if the value to be expressed in the document is 1/10, should the value be written as ".1" or "0.1"?
How is the length of the value ".1" in an EDI document determined?
How is the length of the value "0.1" in an EDI document determined?
Is "0.1" technically invalid because the specification advises suppressing leading zeros?
Additionally, I would like to understand how the length of a value relates to the use of exponents. For example, the number 1000 can be written in EDI as either 1E3 or 1000.
Will the length of this value differ depending on which notation is used (2 and 4, respectively)?
daniel.bauman last edited by
- It should be written as ".1".
- As section 126.96.36.199 states [The length of a decimal type data element does not include the optional minus signs, decimal point, or trailing exponent indicator "E".] the length of ".1" is 1.
- The length of "0.1" is determined as it is given. In this case an EDI element with value "0.1" is 2.
- Answering this question in two parts:
4.1 According to the spec "0.1" should be written as ".1" in an EDI element unless leading 0s are required to pad the number to meet a minimum length constraint.
4.2 1000 will have length 4 when written as "1000" and length 2 when written as "1E3".
- It will, "0.1" has length 2 and ".1" has length 1 even though the same numeric quantity is being represented by both.
You can see some of these details discussed in this request for clarification on the x12 website - https://x12.org/resources/requests-for-interpretation/rfi-2596-request-clarification-representation-numeric-types