[Ktechlab-devel] public service announcement
Alan Grimes
agrimes at speakeasy.net
Thu Jun 26 17:36:45 UTC 2008
I'm searching through the code for hard coded constants..........
I hope everybody is aware that math.h (C), and it's successor, cmath
(C++) contains #defines for just about every irrational constant you
might require defined out to the limits of machine precision...
For example, the code:
y = x / 1.44;
should be written as:
y = X * M_SQRT1_2;
since dividing something is equivalent to multiplying by it's
reciprocal, and since the designers of C++ thoughtfully included the
reciprocal as a constant, and because multiplication is a faster
operation, this is the preferred method. =)
--
Ron Paul: A man of Peace.
Chemistry.com: A total rip-off.
Powers are not rights.
We did not invade Iraq, the government did.
More information about the Ktechlab-devel
mailing list