Hi all,
I've been using the the Frac( X: Real ): Real; function to return the
remainder in a prime number sieve for double data types.
ie:
procedure TForm1.dblPrimeButton(Sender: TObject);
var
x, y: double;
begin
// do stuff
if ( Frac(x/y) = 0 ) then
begin
prime := false;
break
end;
// do some more stuff
end;
In most C math libs., there is a double fmod( double x, double y ) function
that returns the remainder.
Is there such an "fmod" function in Delphi? Frac will do what I want, but
I'm just curious if there is a better method.
--
---------------------------------------------------------------
| Dave Fladebo |
| IS Manager |
| da...@gosportsmens.com |
| |
| My opinions may not reflect those of my employer. |
---------------------------------------------------------------
BTW - Please Cc: my e-mail address.
Dave <da...@gosportsmens.com> wrote in article
<01bc4438$eadc6160$f6dcc7c7@ws1>...
nothing built in that I know of, but y*frac(x/y) will get you what
you want...if it's speed you need, you may want to get a copy of
J. D. Gayrard's MathLib2 (try the Delphi Super Page), which has an
implementation of fmod() coded in assembler
Mark Vaughan
>In most C math libs., there is a double fmod( double x, double y ) function
>that returns the remainder.
>
>Is there such an "fmod" function in Delphi? Frac will do what I want, but
>I'm just curious if there is a better method.
Delphi does not have such a function, but it is easy to write:
function FMod(X, Y: Extended): Extended;
asm
FLD Y
FLD X
FPREM1
FWAIT
end;
--
Ray Lischner (send email to "lisch" at tempest-sw.com)
Author of Secrets of Delphi 2 (http://www.tempest-sw.com/secrets/)