🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #12046

Re: Is double->int slow?

#12046
From: Herman Rubin
Date: Thu, 13 Jun 1991 11:10
36 lines
2217 bytes
In article <1991Jun12.014037.26495@cl.cam.ac.uk>, cet1@cl.cam.ac.uk (C.E. Thompson) writes:
> In article <COGSWELL.91Jun11112827@MEAT.cs.cmu.edu> cogswell@MEAT.cs.cmu.edu (Bryce Cogswell) writes:
> >Double to int conversion on the RS/6000 is done in software, and
> >requires 17-39 instructions.
> >
> That's mind-bogglingly many. If it doesn't violate any legal nicety, could
> you post the details?
> 
> The tedious aspect of double->int conversion in software is usually the
> range check. After that, with an IEEE754 implemnetation, adding a suitable
> constant to move the integer part to the low-order bits of the mantissa and
> simulataneously bias by 2**31 does the trick.

Range checking is also simple in hardware compared to software.  But ignoring
this, how much is involved?  I am assuming that the situation will be that 
the double number is in a register, and that the integer is wanted in a 
register.

	Add constant to double
	Store result
	Load lower part in integer register
	Toggle sign bit

If it is known that the answer is non-negative, changing the constant
allows ignoring the last step, and also allows one more bit for an
unsigned result.

Converting integer to double is the reverse of this.  And suppose one 
wants the integer and fraction as well as doubles?  This should not
be done as a separate project, but 3 more instructions are needed,
all floating.  This is the also the case if only the fraction is
wanted.
-- 
Herman Rubin, Dept. of Statistics, Purdue Univ., West Lafayette IN47907-1399
Phone: (317)494-6054
hrubin@l.cc.purdue.edu (Internet, bitnet)   {purdue,pur-ee}!l.cc!hrubin(UUCP)
Technical Details
Message-ID: <13496@mentor.cc.purdue.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!sdd.hp.com!news.cs.indiana.edu!news.nd.edu!mentor.cc.purdue.edu!pop.stat.purdue.edu!hrubin
References: <1991Jun6.172905.5304@vax5.cit.cornell.edu> <1991Jun12.014037.26495@cl.cam.ac.uk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!sdd.hp.com!news.cs.indiana.edu!news.nd.edu!mentor.cc.purdue.edu!pop.stat.purdue.edu!hrubin
From: hrubin@pop.stat.purdue.edu (Herman Rubin)
Newsgroups: comp.arch
Subject: Re: Is double->int slow?
Summary: Another reason to do it in hardware
Message-ID: <13496@mentor.cc.purdue.edu>
Date: 13 Jun 91 11:10:49 GMT
References: <1991Jun6.172905.5304@vax5.cit.cornell.edu> <1991Jun12.014037.26495@cl.cam.ac.uk>
Sender: news@mentor.cc.purdue.edu
Distribution: comp
Lines: 36