Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!mit-eddie!genrad!decvax!decwrl!pyramid!oliveb!intelca!mipos3!omepd!kinder From: kinder@omepd.UUCP Newsgroups: comp.lang.ada Subject: Re: problem with using bitfields Message-ID: <411@omepd> Date: Tue, 17-Feb-87 01:11:59 EST Article-I.D.: omepd.411 Posted: Tue Feb 17 01:11:59 1987 Date-Received: Thu, 19-Feb-87 05:48:40 EST Sender: news@omepd Reply-To: kinder@inteloa.UUCP (David B. Kinder) Organization: Intel Corp., Hillsboro Lines: 19 In message 148, Rick writes that a compiler complained about a record field of type "POSITIVE range 0..1" when a rep clause tries to pack this field into one bit (and similarly when a field of type "POSITIVE range 0..2**6-1" is packed into 6 bits). Since the type POSITIVE is a subtype of INTEGER, the compiler is probably complaining because you haven't left room for a "sign" bit. In many architectures, there is a difference between integer (signed) and ordinal (unsigned) operations (such as, whether arithmetic overflow is raised). The compiler may have decided that since you used a subtype of an integer type, you intend for integer-like behavior, and because of this, you need to leave room for one more bit for the sign, (even though your subtype's range can have no negative values). The easiest way to determine this compiler behavior is to try a rep-clause to pack the fields into 2 bits and 7 bits respectively. There may also be a pre-defined numeric type available (perhaps in System) that is an unsigned numeric type that you can use and would not require a sign bit.