Also, if you create a signed number type such as xs:int, then the bits of a bit-field element will be interpreted as a signed number, twos complement. So the most-significant bit of the field will be interpreted as a sign bit (for any field with > 1 bit).
So a 3 bit field can have values -4, -3, -2, -1, 0, 1, 2, 3. Usually people want unsignedInt for bit fields so that a 3 bit field gets values 0, 1, 2, 3, 4, 5, 6, or 7. ________________________________ From: Beckerle, Mike <[email protected]> Sent: Friday, February 15, 2019 11:44:31 AM To: [email protected] Subject: Re: I don't understand bitOrder - please help! This bitOrder feature is very thoroughly tested, so I suspect your tests are missing something important. dfdl:lengthUnits="bits" dfdl:alignment="1" dfdl:alignmentUnits="bits" dfdl:representation="binary" dfdl:binaryNumberRep="binary" Those properties are really essential. ________________________________ From: Costello, Roger L. <[email protected]> Sent: Friday, February 15, 2019 11:14:18 AM To: [email protected] Subject: Re: I don't understand bitOrder - please help! Thanks Steve and David! To follow up on Steve's example ... The input is: 01011001 With this element declaration: <xs:element name="bit3" type="xs:int" dfdl:length="3" dfdl:bitOrder="mostSignificantBitFirst"... /> The value of <bit3> will be binary 010 (decimal 2), right? With this element declaration: <xs:element name="bit3" type="xs:int" dfdl:length="3" dfdl:bitOrder="leastSignificantBitFirst"... /> The value of <bit3> will be binary 001 (decimal 1), right? That is not the behavior that I got with my tests. /Roger -----Original Message----- From: Steve Lawrence <[email protected]> Sent: Friday, February 15, 2019 8:50 AM To: [email protected]; David Winant <[email protected]> Subject: Re: [EXT] Re: I don't understand bitOrder - please help! That's correct. As a minimal example, let's imagine we had one byte of data like so, with bits labels A-H: Label: ABCDEFGH Bits: 01011001 Imagine we had an element like so: <xs:element name="bit3" type="xs:int" dfdl:length="3" ... /> So an integer with length 3 bits. With bitOrder = MSBF, we would read the 3 most significant bits first. So bits A-C and a value of 2 (010). If there was a following element, the next bit read would be bit D. With bitOrdre = LSBF, we would read the 3 least significant bits first. So bits F-H and a value of 1 (001). If there was a following element, the next bit read would be bit E. On 2/15/19 8:33 AM, David Winant wrote: > Roger, > > "Most significant" is implied as leftmost because that is the way we > write numbers. It means the bit associated with the highest power of > 2, 2^7 in the case of a byte. > > What the bitOrder controls is whether the "first" bit is read from the > right or read from the left. > > David > > On Fri, Feb 15, 2019 at 8:13 AM Costello, Roger L. <[email protected] > <mailto:[email protected]>> wrote: > > Hi Mike,____ > > __ __ > > * Least significant bit first or LSBF, the first bit is the rightmost > zero.____ > > __ __ > > So the most significant bit is the leftmost one.____ > > __ __ > > * Most significant bit first, MSBF, the first bit is the 1 on > the left.____ > > __ __ > > So the least significant bit is the rightmost zero.____ > > __ __ > > Aren't they saying the same thing: The most significant bit is the > leftmost > one and the least significant bit if the rightmost zero. What's the > value/benefit/use-case of specifying bitOrder? ____ > > __ __ > > /Roger____ > > __ __ > > *From:* Beckerle, Mike <[email protected] > <mailto:[email protected]>> > *Sent:* Friday, February 15, 2019 8:02 AM > *To:* [email protected] <mailto:[email protected]> > *Subject:* [EXT] Re: I don't understand bitOrder - please > help!____ > > __ __ > > Probably bit order should have been called bit numbering system. > ____ > > It does nothing for whole bytes.____ > > It is only about which bits are considered to occupy which index > positions. ____ > > So given byte with value 128, base 2 that is 80 hex or 10000000. So is the > "first" bit a 1 or a zero?____ > > Least significant bit first or LSBF, the first bit is the rightmost zero. > Most significant bit first, MSBF, the first bit is the 1 on the > left. ____ > > Many format standards describe the bits numbering from right to left. > > > > > ____ > > Get Outlook for Android <https://aka.ms/ghei36>____ > > __ __ > > > ---------------------------------------------------------------------- > ---------- > > *From:*Costello, Roger L. <[email protected] <mailto:[email protected]>> > *Sent:* Friday, February 15, 2019 7:33:29 AM > *To:* [email protected] <mailto:[email protected]> > *Subject:* I don't understand bitOrder - please help! ____ > > ____ > > Hello DFDL community,____ > > ____ > > I've read the portions of the specification that discuss bitOrder. > I'm lost.____ > > ____ > > I ran some tests to get a feel for the difference between > leastSignificantBitFirst and mostSignificantBitFirst. See below. Based on > my > tests, it appears there is no difference between leastSignificantBitFirst > and mostSignificantBitFirst. Would you explain what this bitOrder stuff is > all about, please? /Roger____ > > ____ > > ____ > > > > -- > > David Winant |*Trident Systems Incorporated *Sr. Software Engineer, > Integrated Systems Engineering Group > 10201 Fairfax Boulevard > <https://maps.google.com/?q=10201+Fairfax+Boulevard+%7C+Suite+300+%7C+ > Fairfax,+VA+22030&entry=gmail&source=g> | Suite 300 > <https://maps.google.com/?q=10201+Fairfax+Boulevard+%7C+Suite+300+%7C+ > Fairfax,+VA+22030&entry=gmail&source=g> | Fairfax, VA 22030 > <https://maps.google.com/?q=10201+Fairfax+Boulevard+%7C+Suite+300+%7C+ > Fairfax,+VA+22030&entry=gmail&source=g> > > d: 703.267.6014 | c: 304.237.4960 | f: 703.359.6226 > e: [email protected] <mailto:[email protected]> | > www.tridsys.com<http://www.tridsys.com> <http://www.tridsys.com/> > > ** > > 143x59-trident-logo-web-small > > /Notice: The information contained in this email message is considered > confidential and proprietary to the sender and is intended solely for > review and use by the named recipient. Any unauthorized review, use > or distribution is strictly prohibited. If you have received this > message in error, please advise the sender by reply email and delete > the message./ >
