Re: finding primes




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/

.



Relevant Pages

  • Re: finding primes
    ... In any language I'm familar with, if you found an n where that ... Not very familiar with floating point, ... On 64 bit standard IEEE 754 floating point ... Most modern systems have full 64 bit integers ...
    (comp.programming)
  • Re: Linear Algebra Challenge
    ... Since I'm using floating point, so I'll never be able to calculate one ... floating point math set to 99 digits. ... As close as I'm willing to wait if I use arbitrary precision. ... This mode is fast; when you select arbitry ...
    (comp.sys.hp48)
  • Re: Floating point environment
    ... In all functions like fetestexcept, for instance, it is assumed that there is only one floating point environment ... one for double precision ... the 64 bit format and another for the 80 bit format. ... All versions of SSE use a status/control word separate from the main FPU, however, so they can indeed be considered a separate environment. ...
    (comp.std.c)
  • Re: ML matrices multiplication accuracy
    ... Core Duo Processor T2500), I got all 9 cases exactily the same: ... accept just two floating point inputs and then round the result back down ... to 53 bits precision each time. ... I know that there are such instructions ...
    (comp.soft-sys.matlab)
  • Re: This calculation is just wrong / computer cant count!
    ... This is because of how 64-bit floating point arithmetic works. ... Any finite precision arithmetic, whether it is ... significant digits yourself. ... So we have units of inches, feet, ...
    (microsoft.public.vc.mfc)