You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@daffodil.apache.org by "Costello, Roger L." <co...@mitre.org> on 2019/01/23 11:34:02 UTC
Does DFDL have multiple ways to represent signed integers?
Hello DFDL community,
The Windows EXE file format has several fields that contain signed integers.
I remember from school days that there are several ways a binary string can represent signed integers:
Sign & magnitude
2's complement
Which ways does DFDL support?
The EXE specification doesn't specify whether a signed integer will be in sign & magnitude form or 2's complement form (or some other form). If not specified, should I assume 2's complement?
/Roger
Re: Does DFDL have multiple ways to represent signed integers?
Posted by Steve Lawrence <sl...@apache.org>.
The dfdl:binaryNumberRep property defines how binary numbers are
represented. For signed types, a value of "binary" means two's
complement. Other values for the property for signed types can be
"packed" (IBM 390 packed decimal) an "ibm4690Packed". So DFDL does not
support sign-magnitude or other ways of representing signed binary
numbers. Though, if a format is found where a different reresentation is
needed, we can always discuss adding it. We came across a format that
uses "offset binary", so there is a proposal to add that to Daffodil
(DAFFODIL-1889).
I think generally two's complement is a safe assumption if it's not
specified.
- Steve
On 1/23/19 6:34 AM, Costello, Roger L. wrote:
> Hello DFDL community,
>
> The Windows EXE file format has several fields that contain signed integers.
>
> I remember from school days that there are several ways a binary string can represent signed integers:
>
> Sign & magnitude
> 2's complement
>
> Which ways does DFDL support?
>
> The EXE specification doesn't specify whether a signed integer will be in sign & magnitude form or 2's complement form (or some other form). If not specified, should I assume 2's complement?
>
> /Roger
>