source: CIVL/mods/dev.civl.com/notes/bitwise.txt@ 1aaefd4

main test-branch
Last change on this file since 1aaefd4 was aad342c, checked in by Stephen Siegel <siegel@…>, 3 years ago

Performing huge refactor to incorporate ABC, GMC, and SARL into CIVL repo and use Java modules.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5664 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 1.2 KB
Line 
1
2Some notes on implementing bit-wise operations in CIVL:
3
4Read C11 6.2.6 on Representation of Types, esp. integer types.
5
66.5.7 Bitwise shift operators
7
8The integer promotions are performed on each of the operands.
9The type of the result is that of the promoted left operand.
10If the value of the right operand is negative or is
11greater than or equal to the width of the promoted left operand,
12the behavior is undefined.
13
14The result of E1 << E2 is E1 left-shifted E2 bit positions;
15vacated bits are filled with zeros. If E1 has an unsigned type,
16the value of the result is E1 * 2^E2, reduced modulo one more
17than the maximum value representable in the result type.
18If E1 has a signed type and nonnegative value, and E1 * 2^E2
19is representable in the result type, then that is the resulting
20value; otherwise, the behavior is undefined.
21
22The result of E1 >> E2 is E1 right-shifted E2 bit positions.
23If E1 has an unsigned type or if E1 has a signed type and a
24nonnegative value, the value of the result is the integral
25part of the quotient of E1 / 2E2. If E1 has a signed type
26and a negative value, the resulting value is
27implementation-defined.
28
29See 6.5.10--12 for the bit-wise and, inclusive or, exclusive or
30operations. But all it says is that these are the bit-wise
31operations.
Note: See TracBrowser for help on using the repository browser.