In a similar vein, I would expect that most comparison shopping sites (kelkoo, froogle.google, shopping.yahoo, etc.) would have to start paying license fees to display price information.
Using parentheses better might help... 1/2*3.14 is much easier to read as: (1/2) * 3.14
To be clear, "/" also applies to division of real numbers. It's just that if both sides of the equation are integers then it will carry out integer division.
1/2 * 3.14 = (1/2) * 3.14 = 0 * 3.14
Admittedly, this does make things difficult to read. When you're scanning through your code, it's hard to spot immediately that the output might not be what you expect.
It's possible to obfuscate any language, so as you become familiar with features such as this, you tend to write them out differently. For instance, you might write this out as ((1.0/2.0) * 3.14) or you could explicitly cast each as a float as in: (float)( ( (float)1 / (float)2 ) * (float)3.14 )
In a similar vein, I would expect that most comparison shopping sites (kelkoo, froogle.google, shopping.yahoo, etc.) would have to start paying license fees to display price information.
Using parentheses better might help ...
1/2*3.14 is much easier to read as:
(1/2) * 3.14
To be clear, "/" also applies to division of real numbers. It's just that if both sides of the equation are integers then it will carry out integer division.
1/2 * 3.14 = (1/2) * 3.14 = 0 * 3.14
Admittedly, this does make things difficult to read. When you're scanning through your code, it's hard to spot immediately that the output might not be what you expect.
It's possible to obfuscate any language, so as you become familiar with features such as this, you tend to write them out differently. For instance, you might write this out as ((1.0/2.0) * 3.14) or you could explicitly cast each as a float as in:
(float)( ( (float)1 / (float)2 ) * (float)3.14 )
Oh but it has already happened ... in a small way.
Or there's one on this page which did 150mph (0-60 in 5 seconds). Not quite the version that was available in the shops though ;)