<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On 14 Jan 2013, at 14:11, Martin wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="font-family: monospace; ">Having recently asked about and learned that it is mainly a hint about performance. I have now another question about this hint:<br> project1.lpr(6,9) Hint: Mixing signed expressions and longwords gives a 64bit result<br><br>Actually not so much about the hint, as about the fact that in the below example fpc extends the operands to 64 bits.<br><br>program Project1;<br>var<br> x: cardinal;<br> i, j: integer;<br>begin<br> i:= x or j<br>end.<br><br>I understand the need for a 64 bit operation for +/-/</>/*/...<br><br>But the "or" operator works bitwise, it does not treat the operands as numbers which could either be signed or unsigned? Or does it? If it does not, why does it need to use 64 bit?<br></span></span></blockquote></div><br><div>Pascal evaluates expressions independent of how their result is used. The result of that "x or j" could just as well be assigned to a 64 bit variable, or e.g. passed to a function that is overloaded with both 32 and 64 bit parameters. In those cases the result type of that expression would matter.</div><div><br></div><div>That said, the compiler contains an optimization pass that tries to remove 64 bit widenings on 32 bit platforms in case it turns out they were not necessary. It will also catch the above example and the generated code will only contain a 32 bit operations. Semantically, the result of that expression remains 64 bit though.</div><div><br></div><div><br></div><div>Jonas</div></body></html>