|
Prime Numbers Revisited
by George
Martin
Start ı Being
Ardent ı An Example ı Sources
and PDF
AN EXAMPLE
Letıs assume that the Area() routine
is similar to Arendtıs. Therefore, in C, the algorithm would look
something like Listing
1.
The comparison to 1e-6 in the example
is shown because floating-point calculations can have round off problems.
For example, (1.0/3.0) ı 3.0 might not equal 1.0, but 0.99999999999
instead. So, the typical approach is to check that the results agree
to within some small error value (often called epsilon).
As you can see, it can be done with just
about the same level of clarity or complication as C++, but there
might be other considerations to take into account.
Does the C++ compiler blow up the code
and make it unusable in embedded systems? Perhaps. Does C++ provide
for simpler thinking for software designers? Perhaps (old dogs and
new tricks). Should we start using C++ tomorrow? No, but it can no
longer be ignored (donıt become obsolete).
All right, Iım done. Iıll get off the
soapbox now. Next month, Iıll talk about the Motorola Coldfire CPU.
PREVIOUS NEXT
Circuit Cellar provides up-to-date information for engineers. Visit
www.circuitcellar.com for
more information and additional articles.
For subscription information, call (860) 875-2199, subscribe@circuitcellar.com
or subscribe online.
ıCircuit Cellar, the Magazine for Computer Applications. Posted with
permission. |