Re: finding primes
- From: dcorbit@xxxxxxxxx
- Date: 30 Oct 2006 23:35:11 -0800
websnarf@xxxxxxxxx wrote:
Azumanga wrote:
CBFalconer wrote:
Azumanga wrote:
dcorbit@xxxxxxxxx wrote:... snip ...
On the other hand, we are assuming that sqrt(n*n) results in
exactly n and not: (n-1)+0.9999999999999999
In any language I'm familar with, if you found an n where that
happened, you'd submit a HUGE bug comment to the people who make the
langauge. Seriously, it you can't count on that working, I don't see
why you think the division is any more likely to work correctly...
Not very familiar with floating point, are you?
I am, and therefore would never have even considered using them to find
if numbers were prime. Surely it would simply be impossible?
Why would it be impossible? On 64 bit standard IEEE 754 floating point
numbers you should be able to write a 53 bit prime number tester. In
particular, look at the modf() function in the C standard library.
Right.
#define DBL_DIG 15 /* # of decimal digits
of precision */
#define DBL_MANT_DIG 53 /* # of bits in
mantissa */
That is two ways of saying the same thing. Of course, the '53 bit'
will be slightly more accurate than 15 digits.
Of course, that has nothing to do with the round off problem which will
happen when you have exceeded the accuracy of the floating point system
that you are using. Most modern systems have full 64 bit integers
which will cover a larger range of integers than double precision
floating point anyways.
--
Paul Hsieh
http://www.pobox.com/~qed/
http://bstring.sf.net/
.
- References:
- finding primes
- From: Digital Puer
- Re: finding primes
- From: Richard Heathfield
- Re: finding primes
- From: Logan Shaw
- Re: finding primes
- From: Richard Heathfield
- Re: finding primes
- From: dcorbit
- Re: finding primes
- From: Azumanga
- Re: finding primes
- From: CBFalconer
- Re: finding primes
- From: Azumanga
- Re: finding primes
- From: websnarf
- finding primes
- Prev by Date: Re: finding primes
- Next by Date: Re: finding primes
- Previous by thread: Re: finding primes
- Next by thread: Re: finding primes
- Index(es):
Relevant Pages
|
|