Thank you Steve! One follow-up question, please. > In order to get a value of 19.95, your data > would contain the bytes 0x07CB (1995 in > two's complement binary) and you'd have > dfdl:binaryDecimalVirtualPoint="2" to > move the decimal point two places to the left.
Is that how most real world data formats express 19.95? If I understand correctly, the 19.95 is treated as the integer 1995 and then the integer 1995 is expressed in binary. Then, the data format must, by some means, indicate that there is a decimal point between 19 and 95. Wouldn't that information about the location of the decimal point either require some additional information within the binary file, or some out-of-band knowledge by the applications that processes the binary file? It seems, based on your description, you are assuming the latter. /Roger -----Original Message----- From: Steve Lawrence <[email protected]> Sent: Monday, September 30, 2019 7:40 AM To: [email protected] Subject: [EXT] Re: How are decimal (number with decimal point) values expressed in a binary file? If the type were xs:float or xs:double, then the dfdl:binaryFloatRep property defines how binary is converted to a number. Daffodil currently only supports "ieee", which is IEEE 754-1985 floating point representation. And byte lengths must be 4 for xs:float or 8 for xs:double. Things are a bit different for xs:decimal. In that case, we parse the number of bits as an integer (based on the dfdl:binaryNumberRep property), and then move the decimal point of that integer base on the value of dfdl:binaryDecimalVirtualPoint. So in your example, let's say your field length was 2 bytes and dfdl:binaryNumberRep="binary" (i.e. two's complement). In order to get a value of 19.95, your data would contain the bytes 0x07CB (1995 in two's complement binary) and you'd have dfdl:binaryDecimalVirtualPoint="2" to move the decimal point two places to the left. On 9/30/19 7:19 AM, Costello, Roger L. wrote: > Hello DFDL community, > > Scenario: The book cost is: 19.95 > > The book data is in binary. > > How is 19.95 expressed in binary? > > How would the cost be expressed in a DFDL schema? Simply this: > > <xs:element name="cost" type="decimal" /> > > /Roger >
