41
Programming with NASM / Re: Problem with calculating root
« Last post by fredericopissarra on January 30, 2025, 08:44:01 PM »I have another version of my program, in which I use the fp87 for getting the squareroot. I test both.
The huge amount of divisions to see, what is prime and what not, is in the moment done by normal DIV command. But later, I will try to do this with fp87, and a third version to do it with sse2.
You don't need floating point or square root... Here:
Code: [Select]
_Bool isprime( unsigned int n )
{
unsigned int d;
unsigned long long int f;
if ( n <= 3 )
return n >= 2;
d = n % 6;
if ( d != 1 && d != 5 )
return 0;
for ( f = 5; f * f <= n; f += 2 )
if ( ( n % f ) == 0 )
return 0;
return 1;
}
Recent Posts