Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
language:expressions [2026/09/13 12:52] – [Idiosyncrasies] rajitlanguage:expressions [2026/09/13 12:53] (current) – [Idiosyncrasies] rajit
Line 148: Line 148:
  
 This points out that the subtraction operation ''(x-1)'' will produce a result that is five bits in all cases. However, it is used in a context where 8 bits are needed. In this context, the result will be zero-extended to 8 bits. Note that this may in fact be what was intended, which is why this is a user-controlled warning that can be turned on to double-check CHP expressions. This points out that the subtraction operation ''(x-1)'' will produce a result that is five bits in all cases. However, it is used in a context where 8 bits are needed. In this context, the result will be zero-extended to 8 bits. Note that this may in fact be what was intended, which is why this is a user-controlled warning that can be turned on to double-check CHP expressions.
 +
 +Similarly, the following program:
 +<code act>
 +int<4> x;
 +int<8> y;
 +...
 +chp {
 +   ...
 +   y := ~x;
 +   ...
 +}
 +</code>
 +will trigger the warning
 +<code>
 +WARNING: Complement operation needs bitwidth 8, but has bitwidth 4
 + Sub-expression: x
 +</code>
  
 ==== Conversion from/to integer to/from pure structures ==== ==== Conversion from/to integer to/from pure structures ====