From: "John M. Aldrich" 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 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk 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 >>> | ---------------------------------------------------------------------