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

Converting Extended to Integer

2,101 views
Skip to first unread message

Borut Zagar

unread,
May 22, 2000, 3:00:00 AM5/22/00
to
Hi.

I use Delphi 5 and I dont know how to convert variables of type Extended to
other types, e.g. Integer.
I am sure it can be done, but Delphi 5 help is useless.

In my program I want to calculate mod between two variables of Extended
type. Can I do this in another way thaen converting these two variables to
integer and then do "a mod b"?

Thank you for your help,
Borut Zagar


Darius Blaszijk

unread,
May 23, 2000, 3:00:00 AM5/23/00
to
Try Round, or Trunc. Whatever suits best.

Darius Blaszijk

Borut Zagar wrote in message <3929...@news.perftech.si>...

Toralf Richter

unread,
May 24, 2000, 3:00:00 AM5/24/00
to
Borut Zagar <borut...@zaslon.si> wrote:
> Hi.

> I use Delphi 5 and I dont know how to convert variables of type Extended to
> other types, e.g. Integer.
> I am sure it can be done, but Delphi 5 help is useless.

> In my program I want to calculate mod between two variables of Extended
> type. Can I do this in another way thaen converting these two variables to
> integer and then do "a mod b"?

> Thank you for your help,
> Borut Zagar

Hi,

I would try it with an equation. As you probably know the mod operator can
be expressed as a mod b = a - a div b. So you can use the last statement to
express your mod operator on two Extended numbers. Just type

mod := a - Trunc(a / b);

Then you get your mod.
Good luck.

cu,
Toralf

M.H. Avegaart

unread,
May 24, 2000, 3:00:00 AM5/24/00
to
Trunc() introduces an extra Extended to Integer to Extended conversion.
Instead use:

mod := a - Int(a / b);


"Toralf Richter" <tr...@irz787.inf.tu-dresden.de> schreef in bericht
news:8ggnai$45o$1...@irz787.inf.tu-dresden.de...

0 new messages