Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Attn: math library gurus; Frac function

0 views
Skip to first unread message

Dave

unread,
Apr 8, 1997, 3:00:00 AM4/8/97
to

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. |
---------------------------------------------------------------

Dave

unread,
Apr 8, 1997, 3:00:00 AM4/8/97
to

BTW - Please Cc: my e-mail address.

Dave <da...@gosportsmens.com> wrote in article
<01bc4438$eadc6160$f6dcc7c7@ws1>...

Mark Vaughan

unread,
Apr 9, 1997, 3:00:00 AM4/9/97
to

In article <01bc4438$eadc6160$f6dcc7c7@ws1>,
"Dave" <da...@gosportsmens.com> wrote:
]-
]-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.
]-

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

Ray Lischner

unread,
Apr 9, 1997, 3:00:00 AM4/9/97
to

On 8 Apr 97 16:23:45 GMT, "Dave" <da...@gosportsmens.com> wrote:

>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/)

0 new messages