Mail Archives: djgpp/1997/06/06/12:09:35
From: | "John M. Aldrich" <fighteer AT cs DOT com>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: how to convert float ->int?
|
Date: | Fri, 30 May 1997 22:28:45 +0000
|
Organization: | Two pounds of chaos and a pinch of salt
|
Lines: | 35
|
Message-ID: | <338F549D.375A@cs.com>
|
References: | <01bc6dff$6cbac9c0$10ee13cb AT bbs>
|
Reply-To: | fighteer AT cs DOT com
|
NNTP-Posting-Host: | ppp105.cs.com
|
Mime-Version: | 1.0
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
abcEd wrote:
>
> whats the best way of converting from float to int?
> and how to pass float parameters into inline asm so that
> fpu(intel) can use them?
Use C's typecast system. Exactly how depends on the accuracy you're
looking for.
Assuming:
int a;
float f;
To get a truncated integer, use:
a = (int) f;
or just
a = f;
To get a rounded integer, use:
a = f + 0.5;
I don't know enough inline asm to help you with the latter, but it's
little different from passing integer parameters. See the gcc
documentation in "info gcc".
hth
--
---------------------------------------------------------------------
| John M. Aldrich, aka Fighteer I | mailto:fighteer AT cs DOT com |
| God's final message to His Creation: | http://www.cs.com/fighteer |
| "We apologize for the inconvenience."| <<< This tagline under >>> |
| - Douglas Adams | <<< construction >>> |
---------------------------------------------------------------------
- Raw text -