🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #12017

Re: Is double->int slow?

#12017
From: Mike Weaver
Date: Mon, 10 Jun 1991 22:05
25 lines
1896 bytes
In article <1991Jun6.172905.5304@vax5.cit.cornell.edu> umh@vax5.cit.cornell.edu writes:
>... 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

I wasn't able to find out about the RS/6000, but a double to int
conversion is not inherently more complicated than a floating point
add. On our (Weitek) hardware, as used in Sun workstations, double to
int and float to int both take the same time as adding two floats or
adding two doubles. Converting the other way is similar, except that
for int to float takes twice as long, because of an extra rounding step
since 32 bits (int) may not fit into the float significand.

However, floating point to/from integer conversions are notorious for
being slow, mostly because they are considered infrequent operations
and therefore not worth much expense in hardware. I would not be
surprised if the conversions were done in software on some present day
machines with generally good floating point performance.
Technical Details
Message-ID: <1991Jun10.220533.19560@jetsun.weitek.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!oliveb!veritas!amdcad!jetsun!weaver
References: <1991Jun6.172905.5304@vax5.cit.cornell.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!oliveb!veritas!amdcad!jetsun!weaver
From: weaver@jetsun.weitek.COM (Mike Weaver)
Newsgroups: comp.arch
Subject: Re: Is double->int slow?
Message-ID: <1991Jun10.220533.19560@jetsun.weitek.COM>
Date: 10 Jun 91 22:05:33 GMT
References: <1991Jun6.172905.5304@vax5.cit.cornell.edu>
Reply-To: weaver@jetsun.WEITEK.COM (Michael Weaver)
Distribution: comp
Organization: WEITEK, Sunnyvale CA
Lines: 25