# Section 8.2.2.1:
BIT

immutable class BIT < $IS_EQ

Formal Types

types

SAME = BIT ;
BIT = token

This class is a slight enhancement of the pervasive class BIT which has no conversion facilities (create and card below). It provides the binary digit object which is the fundamental component of all objects defined in a computer system. The two possible values are setbit and clearbit.

NOTES | 1. The corresponding pervasive class has no inheritance - because it is pervasive!
| 2. This class is defined in such a way that an implementation is not required to specify in what way the object is implemented, nor, indeed, to specify that it will always have the same implementation representation. Any use which attempts to rely on some particular representation is erroneous.

create | (
| val : CARD
| ) : SAME

Formal Signature

create(val : CARD) res : BIT

Post-condition

res.set = (val = 1)

This creation routine is really a conversion from a numeric value to a bit value. If the numeric value is 1 then the bit value is setbit, otherwise clearbit.

card | : CARD

Formal Signature

card(self : SAME) res : CARD

Post-condition

((res = 0)

and self.clear)

or ((res = 1)

and self.set)

This conversion routine returns 1 if self is set, otherwise zero.

is_eq | (
| other : SAME
| ) : BOOL

Formal Signature

is_eq(self : SAME, other : SAME) res : BOOL

Post-condition

res = (self = other)

This predicate returns true if and only if self and other have the same value, otherwise false.

set | : BOOL

Formal Signature

set(self : SAME) res : BOOL

Post-condition

res = (self = setbit)

This predicate returns true if and only if self has the value setbit, otherwise false.

clear | : BOOL

Formal Signature

clear(self : SAME) res : BOOL

Post-condition

res = (self = clearbit)

This predicate returns true if and only if self has the value clearbit, otherwise false.

| Language Index |  | Library Index |  | Binary Index

Comments or enquiries should be made to Keith Hopper . Page last modified: Wednesday, 22 March 2000. |