![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
Join Date: Nov 2004
Location: 1691 miles East of L.A.
Posts: 159
Rep Power: 4
![]() |
here's the slightly improved c code.
/*straight c code .00192 sec. number tested 111111113*/
/* .00449 sec alt test number tested 654159511*/
int is_prime2(int n){
int i,k;
if (n<=3)return 1;
if(n&1==0)return 0;
k=sqrt(n)+1;
for (i=3;i<=k;i+=2){
if(n%i==0)return 0;
}
return 1;
}
__________________
-- lostcauz Stepped in what?... Behind whose barn?... I didn't even know they had a cow! |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Nov 2004
Location: 1691 miles East of L.A.
Posts: 159
Rep Power: 4
![]() |
Now the pointer contains roughly the square root of the number we are testing for prime. We will now *blaze* to the result. :rock:
__________________
-- lostcauz Stepped in what?... Behind whose barn?... I didn't even know they had a cow! |
|
|
|
|
|
#3 |
|
Expert Programmer
|
So curiously, what C/C++ code did you compare this execution too? I suspect that one would be able to match the speed of execution without having to break down into an inline assembly at all.
__________________
Clifford Matthew Roche <geek@cliffordroche.com> Web Hosting: http://www.crd-hosting.com Consulting: http://www.crdev-consulting.com |
|
|
|
|
|
#4 | |
|
Hobbyist Programmer
Join Date: Nov 2004
Location: 1691 miles East of L.A.
Posts: 159
Rep Power: 4
![]() |
The C code was listed in the first post as was this statement.
Quote:
![]()
__________________
-- lostcauz Stepped in what?... Behind whose barn?... I didn't even know they had a cow! |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|