<div class="gmail_quote">On 13 January 2012 21:31, bearophile <span dir="ltr"><<a href="mailto:bearophileHUGS@lycos.com">bearophileHUGS@lycos.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">> What I wonder is why this operator is necessary at all?<br>
<br>
</div>It's not necessary, like most other features in a language, like for loops. But it's handy and very useful, I am now using one power operator about every 40 or 50 lines of D2 code.<br>
<br>
Instead of writing:<br>
result = (complex expression) * (complex expression);<br></blockquote><div><br></div><div>What are you working on if I may ask? I do tend to write a lot of very maths-intensive code (physics, rendering, lighting), and I almost never find myself using any sort of pow, other than ^2, which I'm perfectly happy to type x*x.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Or:<br>
<br>
const aux = complex expression;<br>
result = aux * aux;<br>
<br>
You write:<br>
<br>
result = (complex expression) ^^ 2;<br></blockquote><div><br></div><div>I'm more than happy with aux*aux, in fact, I think I prefer it (probably just through habit). Though I do sort of see your point.</div><div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">And it gets better with cubes.<br></blockquote><div><br></div><div>Realistically, how often do you cube? It's extremely rare in my experience.</div>
</div>