19.11.2014 Views

The Fortress Language Specification - CiteSeerX

The Fortress Language Specification - CiteSeerX

The Fortress Language Specification - CiteSeerX

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

40.5.1 coercion int r(x:IntegerStaticr) where { −2 b−1 ≤ r < 2 b }<br />

An static integer may be coerced to a binary word that corresponds to that integer value when interpreted as either a<br />

signed integer or an unsigned integer. For example, the type BinaryWord3 has 2 (23) = 256 distinct binary word<br />

values; when they are interpreted as signed integers, the integer values range from −128 to 127, and when they are<br />

interpreted as unsigned integers, the integer values range from 0 to 255. <strong>The</strong>refore any static integer from −128 to<br />

255 may be coerced to type BinaryWord3 .<br />

40.5.2 coercion bool bigEndianBytes,bool bigEndianBits<br />

(x:BinaryEndianWordb,bigEndianBytes,bigEndianBits)<br />

Any binary endian word may be coerced to a plain binary word of the same size and value. In effect, this coercion<br />

merely discards the endianness information.<br />

40.5.3 coercion nat b ′ ,nat n,bool bigEndianSequence<br />

(x:BinaryLinearEndianSequenceb ′ , n,bigEndianSequence)<br />

where { 2 b = n · 2 b′ }<br />

A binary linear endian sequence of smaller binary words may be coerced to a single binary word, provided that the<br />

length of the linear sequence is an appropriate power of two, so that the total number of bits in the sequence is the<br />

same as the total number of bits in the resulting binary word. <strong>The</strong> manner in which the elements of the sequence are<br />

used to form the new binary word value respects the endianness of the sequence, so that element 0 of the sequence<br />

supplies the most significant bits of the result if bigEndianSequence is true, but supplies the least significant bits of<br />

the result if bigEndianSequence is false.<br />

40.5.4 coercion nat b ′ ,bool bigEndianBytes,bool bigEndianBits,nat n,bool bigEndianSequence<br />

(x:BinaryEndianLinearEndianSequenceb ′ ,bigEndianBytes,bigEndianBits,<br />

n,bigEndianSequence)<br />

where { 2 b = n · 2 b′ }<br />

A binary endian linear endian sequence of smaller binary endian words may be coerced to a single binary word,<br />

provided that the length of the linear sequence is an appropriate power of two, so that the total number of bits in the<br />

sequence is the same as the total number of bits in the resulting binary word. <strong>The</strong> manner in which the elements of<br />

the sequence are used to form the new binary word value respects the endianness of the sequence, so that element 0<br />

of the sequence supplies the most significant bits of the result if bigEndianSequence is true, but supplies the least<br />

significant bits of the result if bigEndianSequence is false. In effect, the “bytes and bits” endianness information is<br />

simply ignored and discarded.<br />

280

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!