[
https://issues.apache.org/jira/browse/DAFFODIL-1889?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16750193#comment-16750193
]
Michael Beckerle commented on DAFFODIL-1889:
--------------------------------------------
In the table below, what we're calling offsetBinary above, is called modified
twos complement.
These are all the other known variations for encoding of integers. These come
from Standards such as MIL-STD-6016, MIL-STD-6017, and NATO STANAG 5516,
||Binary Value||Unsigned||Twos Complement||Modified Twos
Complement||Sign+Magnitude||Ones Complement||
|000|0|0|-4|+0|+0|
|001|1|+1|-3|+1|+1|
|010|2|+2|-2|+2|+2|
|011|3|+3|-1|+3|+3|
|100|4|-4|0|-0|-3|
|101|5|-3|+1|-1|-2|
|110|6|-2|+2|-2|-1|
|111|7|-1|+3|-3|-0|
> binaryNumberRep='offsetBinary'
> ------------------------------
>
> Key: DAFFODIL-1889
> URL: https://issues.apache.org/jira/browse/DAFFODIL-1889
> Project: Daffodil
> Issue Type: New Feature
> Components: Back End, Front End
> Reporter: Michael Beckerle
> Priority: Minor
>
> Implement the binaryNumberRep 'offsetBinary'.
> This is a good first project for someone new to the Daffodil code base.
> This is a proposal for inclusion in the DFDL language, needed for some
> formats such as STANAG 5516.
> This is also called excess-K, or biased, but I think offset binary is a
> better description of it.
> In this representation you take an unsigned binary, and just subtract an
> offset. E.g., for a 3-bit number, mostSignificantBitFirst:
> bits unsigned twos-comp offsetBinary
> 000 0 0 -4
> 001 1 1 -3
> 010 2 2 -2
> 011 3 3 -1
> 100 4 -4 0
> 101 5 -3 1
> 110 6 -2 2
> 111 7 -1 3
> At the moment, users have to work around this in Daffodil using
> inputValueCalc and outputValueCalc. This is feasible, but really awkward for
> such a simple concept.
> The DFDL spec would change so table 13.7 allows 'offsetBinary' for the signed
> integer types.
> The lengthKind would have to be implicit or explicit. (SDE otherwise).
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)