🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #11969

Is double->int slow?

#11969
From: umh
Date: Thu, 06 Jun 1991 21:29
16 lines
1288 bytes
I have a set of routines that perform a lot of double-> int conversions. These
are things like I interpolate some real number, then truncate that to use as an
index into an array of pixel values. Anyway profiling tells me that 20% of my
time is spent in these casts of a double to an int. This seems to me very high-
the interpolation and other fiddling are a large part of my code. 

So my point is: is the conversion of a float or double to an int, an inherently
expensive process- ie more than 1 or 2 clocks? Is it normally done in the FPU,
or is it done in software? Or does the C casting of double to int do something
strange over and above the straight conversion- some sort of consistency checks
or such that eat up ti?

For what it's worthm I'm working on an RS/6000, but I'd be interested to hear
about how this is handled under any modern architecture.

Maynard Handley
Technical Details
Message-ID: <1991Jun6.172905.5304@vax5.cit.cornell.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!rpi!batcomputer!cornell!vax5.cit.cornell.edu!umh

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!rpi!batcomputer!cornell!vax5.cit.cornell.edu!umh
From: umh@vax5.cit.cornell.edu
Newsgroups: comp.arch
Subject: Is double->int slow?
Message-ID: <1991Jun6.172905.5304@vax5.cit.cornell.edu>
Date: 6 Jun 91 21:29:05 GMT
Distribution: comp
Organization: CIT, Cornell University
Lines: 16