Re: Example in the overview

2010-05-14 Thread Walter Bright
Steven Schveighoffer wrote: A comment to explain the representation of the array may be good. Well, I did add your explanation to the bugzilla report! Thanks.

Re: Example in the overview

2010-05-14 Thread Steven Schveighoffer
On Fri, 14 May 2010 19:37:58 -0400, Walter Bright wrote: R.Tenton wrote: At the very bottom of http://digitalmars.com/d/2.0/overview.html there is an example implementation of the Eratosthenes' sieve. That code is broken! It counts 1899 prime numbers, while there are only 1028 primes in t

Re: Example in the overview

2010-05-14 Thread Simen kjaeraas
Walter Bright wrote: bearophile wrote: Walter Bright: Are you sure? What's the mistake in the code? This is the code in the Overview, it prints 1899: http://codepad.org/lzRtggEL This is the code I have suggested in bugzilla, it prints 1027: http://ideone.com/D9ZqQ Wolfram Alpha says they

Re: Example in the overview

2010-05-14 Thread bearophile
Ary Borenszweig: > A small observation: count +=1 is performed for i = 0, hmmm... It lacks unit tests. A basic unit testing can catch that bug. Recently I have ready a quote: "If it has no unit tests then it's broken". Experience shows me that this is more often true than false. Bye, bearophile

Re: Example in the overview

2010-05-14 Thread Ary Borenszweig
Walter Bright wrote: bearophile wrote: Walter Bright: Are you sure? What's the mistake in the code? This is the code in the Overview, it prints 1899: http://codepad.org/lzRtggEL This is the code I have suggested in bugzilla, it prints 1027: http://ideone.com/D9ZqQ Wolfram Alpha says they ar

Re: Example in the overview

2010-05-14 Thread Walter Bright
bearophile wrote: Walter Bright: Are you sure? What's the mistake in the code? This is the code in the Overview, it prints 1899: http://codepad.org/lzRtggEL This is the code I have suggested in bugzilla, it prints 1027: http://ideone.com/D9ZqQ Wolfram Alpha says they are 1027 (I have left ou

Re: Example in the overview

2010-05-14 Thread bearophile
Walter Bright: > Are you sure? What's the mistake in the code? This is the code in the Overview, it prints 1899: http://codepad.org/lzRtggEL This is the code I have suggested in bugzilla, it prints 1027: http://ideone.com/D9ZqQ Wolfram Alpha says they are 1027 (I have left out the last number be

Re: Example in the overview

2010-05-14 Thread Walter Bright
R.Tenton wrote: At the very bottom of http://digitalmars.com/d/2.0/overview.html there is an example implementation of the Eratosthenes' sieve. That code is broken! It counts 1899 prime numbers, while there are only 1028 primes in the interval [1,8191]! Are you sure? What's the mistake in the c

Re: Example in the overview

2010-05-09 Thread R.Tenton
Thanks!

Re: Example in the overview

2010-05-09 Thread bearophile
R.Tenton: > That would be nice. http://d.puremagic.com/issues/show_bug.cgi?id=4164

Re: Example in the overview

2010-05-09 Thread R.Tenton
That would be nice.

Re: Example in the overview

2010-05-09 Thread bearophile
R.Tenton: > Or is this the wrong place to ask? The right place to report errors in the docs is the bugzilla... But if you don't want to subscribe some people here can do it for you. Bye, bearophile

Re: Example in the overview

2010-05-09 Thread R.Tenton
The sieve algorith was not my problem. I wanted to point out that the example is totally screwed up, so it would be corrected. Or is this the wrong place to ask?

Re: Example in the overview

2010-05-08 Thread bearophile
D2 code, the 8191 too is counted: import std.stdio: writeln; int sieve(int m) { auto isPrime = new bool[m + 1]; isPrime[] = true; int count; foreach (i; 2 .. isPrime.length) { if (isPrime[i]) { count++; for (int k = i * 2; k < isPrime.length; k +=

Example in the overview

2010-05-08 Thread R.Tenton
At the very bottom of http://digitalmars.com/d/2.0/overview.html there is an example implementation of the Eratosthenes' sieve. That code is broken! It counts 1899 prime numbers, while there are only 1028 primes in the interval [1,8191]! What is the outermost for loop good for? This example is just