Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #19359

Re: Odd benchmark behavior

Message-ID <4F7D9807.1D82@mindspring.com> (permalink)
Date 2012-04-05 09:03 -0400
From pete <pfiland@mindspring.com>
Organization PF
Newsgroups comp.lang.c
Subject Re: Odd benchmark behavior
References (4 earlier) <4f716921$0$1383$4fafbaef@reader2.news.tin.it> <4F727C20.5A49@mindspring.com> <4f7d7076$0$1379$4fafbaef@reader2.news.tin.it> <4F7D788E.45B9@mindspring.com> <4f7d8b0e$0$1385$4fafbaef@reader1.news.tin.it>

Show all headers | View raw


io_x wrote:
> 
> "pete" <pfiland@mindspring.com> ha scritto nel messaggio
> news:4F7D788E.45B9@mindspring.com...
> > io_x wrote:
> >>
> >> "pete" <pfiland@mindspring.com> ha scritto nel messaggio
> >> news:4F727C20.5A49@mindspring.com...
> >> > io_x wrote:
> >> >>
> >> >> "io_x" <a@b.c.invalid> ha scritto nel messaggio
> >> >> news:4f71688a$0$1383$4fafbaef@reader2.news.tin.it...
> >> >>
> >> >> there is someone that know if  (unsigned) sqrt(9.0) can be
> >> >> follow the C standard the unsigned 2???
> >> >> Thank you
> >> >
> >> > You could do it this way instead:
> >> >
> >> > la:
> >> >    v = p;
> >> >    for (i = ((1 == v) + v) / 2; v > i; i = (p / v + v) / 2) {
> >> >        v = i;
> >> >    }

> > This is the code that you wrote:
> >    #define  u32  uint32_t
> >    u32    i, p, cnt, v;
> > There are no float numbers in that code.

> why this print the wrong result??

> {double  v, i;

That print the wrong result 
because you changed the code to make it wrong.

You already defined (v), (p) and (i) to be all integes,
in your function 
u32  FindNPrime(u32  pos)

The code that I wote, is supposed to be used by you
to replace the line of code that you wrote
at the label la:

la: r=p; v=sqrt(r);

After the line with the lable la:
 What you want is for (v) to be equal to the greatest integer
 with a value less than or equal to the square root of (p).

My suggestion was for you to replace the floating point math
in your FindNPrime function with integer math.

-- 
pete

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Odd benchmark behavior Nils M Holm <news2009@t3x.org> - 2012-03-26 07:51 +0000
  Re: Odd benchmark behavior "io_x" <a@b.c.invalid> - 2012-03-26 11:26 +0200
    Re: Odd benchmark behavior "BartC" <bc@freeuk.com> - 2012-03-26 10:40 +0100
      Re: Odd benchmark behavior gwowen <gwowen@gmail.com> - 2012-03-26 03:37 -0700
      Re: Odd benchmark behavior "io_x" <a@b.c.invalid> - 2012-03-26 14:13 +0200
    Re: Odd benchmark behavior "io_x" <a@b.c.invalid> - 2012-03-26 11:55 +0200
      Re: Odd benchmark behavior "io_x" <a@b.c.invalid> - 2012-03-27 09:17 +0200
        Re: Odd benchmark behavior "io_x" <a@b.c.invalid> - 2012-03-27 09:20 +0200
          Re: Odd benchmark behavior "Scott Fluhrer" <sfluhrer@ix.netcom.com> - 2012-03-27 13:39 -0400
          Re: Odd benchmark behavior pete <pfiland@mindspring.com> - 2012-03-27 21:49 -0500
            Re: Odd benchmark behavior "io_x" <a@b.c.invalid> - 2012-04-05 12:18 +0200
              Re: Odd benchmark behavior pete <pfiland@mindspring.com> - 2012-04-05 06:48 -0400
                Re: Odd benchmark behavior "io_x" <a@b.c.invalid> - 2012-04-05 14:12 +0200
                Re: Odd benchmark behavior pete <pfiland@mindspring.com> - 2012-04-05 09:03 -0400
                Re: Odd benchmark behavior "io_x" <a@b.c.invalid> - 2012-04-05 16:18 +0200
                Re: Odd benchmark behavior "io_x" <a@b.c.invalid> - 2012-04-07 13:26 +0200
                Re: Odd benchmark behavior "io_x" <a@b.c.invalid> - 2012-04-06 09:31 +0200
        Re: Odd benchmark behavior "io_x" <a@b.c.invalid> - 2012-03-27 19:01 +0200
  Re: Odd benchmark behavior "BartC" <bc@freeuk.com> - 2012-03-26 10:36 +0100
    Re: Odd benchmark behavior Nils M Holm <news2009@t3x.org> - 2012-03-26 10:02 +0000
  Re: Odd benchmark behavior Ian Collins <ian-news@hotmail.com> - 2012-03-26 22:58 +1300
  Re: Odd benchmark behavior "BartC" <bc@freeuk.com> - 2012-03-26 15:16 +0100
    Re: Odd benchmark behavior Nils M Holm <news2009@t3x.org> - 2012-03-27 06:20 +0000
      Re: Odd benchmark behavior "BartC" <bc@freeuk.com> - 2012-03-27 10:13 +0100
        Re: Odd benchmark behavior Nils M Holm <news2009@t3x.org> - 2012-03-27 11:59 +0000

csiph-web