The isPrime N was significantly less than the N of the sieve of Eratosthenes. (my fault of course)
So, isPrime gave me 0.570000, while the other remains 0.
The isPrime N was significantly less than the N of the sieve of Eratosthenes. (my fault of course)
So, isPrime gave me 0.570000, while the other remains 0.
Last edited by std10093; 01-24-2013 at 11:12 AM. Reason: typo
Code - functions and small libraries I use
It’s 2014 and I still use printf() for debugging.
"Programs must be written for people to read, and only incidentally for machines to execute. " —Harold Abelson
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
You had the intention to help, so no problem at all
I hope you get better soon!
Code - functions and small libraries I use
It’s 2014 and I still use printf() for debugging.
"Programs must be written for people to read, and only incidentally for machines to execute. " —Harold Abelson
Laserlight - I still think that the book may be right; The wording is ambiguous to me. With regards to the clause -
Does it mean that we may add "is" functions to our program?
does it mean that we can add "is" functions to ctype.h?
does it warn that "is" functions may be added by future standards to ctype.h?
That part of the standard was put there for a reason - I think that the clause which you have sighted fits in better with the third line above, as functions probably shouldn't be added to ctype by everyone (with regard to keeping everything standard), and the clause you quoted does explicitly mentions ctype.h (which would discount the first option).
I think that it is wise to remember that just because everyone does it, doesn't mean that everyone is correct. Also, just because a book suggests something, doesn't mean that it it correct. And lastly, just because we read the standard, it doesn't mean that we interpreted it correctly.
I think that the book is most likely correct, because the argument makes sense: It's a good reason as to why it has been included into the standard. Why else would it be in the standards?
This is the section 7.26 of C99 Draft standards:
7.26 Future library directions
#1
The following names are grouped under individual headers for convenience. All external names described below are reserved no matter what headers are included by the program.
7.26.1 Complex arithmetic <complex.h>
#1
The function names
cerf cexpm1 clog2 cerfc clog10 clgamma * cexp2 clog1p ctgamma |
and the same names suffixed with f or l are reserved for the functions with complex arguments and return values.
7.26.2 Character handling <ctype.h>
#1
Function names that begin with either is or to, and a lowercase letter (possibly followed by any combination of digits, letters, and underscore) may be added to the declarations in the <ctype.h> header.
...
Last edited by Click_here; 01-24-2013 at 05:53 PM. Reason: added quote, fixed font
Fact - Beethoven wrote his first symphony in C
I've found a second source and I'm afraid I'm going to have to concede that you were right, laserlight
The prefix "is" is only reserved when immediately followed by a lowercase letter. (It was there in the standard all along)
isprime would be a reserved name, but isPrime is fine.
Fact - Beethoven wrote his first symphony in C
Code - functions and small libraries I use
It’s 2014 and I still use printf() for debugging.
"Programs must be written for people to read, and only incidentally for machines to execute. " —Harold Abelson
Question 7 solved in 5 minutes.
Question 10 is not solved yet :/
I think that the sum can't hold the result (due to precision). What type should it be?
I printed the primes numbers until 2000000 and I got
the sum must be a BIG number...Code:.. .. 1999891 1999957 1999969 1999979 1999993
Last edited by std10093; 01-25-2013 at 12:06 PM.
Code - functions and small libraries I use
It’s 2014 and I still use printf() for debugging.
"Programs must be written for people to read, and only incidentally for machines to execute. " —Harold Abelson
SOLVED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (now I will try out to find how I fixed it :P )
Code - functions and small libraries I use
It’s 2014 and I still use printf() for debugging.
"Programs must be written for people to read, and only incidentally for machines to execute. " —Harold Abelson
Νο! I mean 5 minutes to write the code for the question
For the history : The problem was on precision of a return value of a function.
Performance :
Question 7: 40ms
Question 10 : 50 ms
Thanks again everybody! I got very excited with all this!
Last edited by std10093; 01-25-2013 at 01:12 PM.
Code - functions and small libraries I use
It’s 2014 and I still use printf() for debugging.
"Programs must be written for people to read, and only incidentally for machines to execute. " —Harold Abelson