1112158Sdas/**************************************************************** 2112158Sdas 3112158SdasThe author of this software is David M. Gay. 4112158Sdas 5112158SdasCopyright (C) 1998, 1999 by Lucent Technologies 6112158SdasAll Rights Reserved 7112158Sdas 8112158SdasPermission to use, copy, modify, and distribute this software and 9112158Sdasits documentation for any purpose and without fee is hereby 10112158Sdasgranted, provided that the above copyright notice appear in all 11112158Sdascopies and that both that the copyright notice and this 12112158Sdaspermission notice and warranty disclaimer appear in supporting 13112158Sdasdocumentation, and that the name of Lucent or any of its entities 14112158Sdasnot be used in advertising or publicity pertaining to 15112158Sdasdistribution of the software without specific, written prior 16112158Sdaspermission. 17112158Sdas 18112158SdasLUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 19112158SdasINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. 20112158SdasIN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY 21112158SdasSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 22112158SdasWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER 23112158SdasIN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 24112158SdasARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 25112158SdasTHIS SOFTWARE. 26112158Sdas 27112158Sdas****************************************************************/ 28112158Sdas 29165743Sdas/* Please send bug reports to David M. Gay (dmg at acm dot org, 30165743Sdas * with " at " changed at "@" and " dot " changed to "."). */ 31112158Sdas 32112158Sdas#include "gdtoaimp.h" 33112158Sdas 34112158Sdas double 35112158Sdasulp 36112158Sdas#ifdef KR_headers 37219557Sdas (x) U *x; 38112158Sdas#else 39219557Sdas (U *x) 40112158Sdas#endif 41112158Sdas{ 42112158Sdas Long L; 43219557Sdas U a; 44112158Sdas 45112158Sdas L = (word0(x) & Exp_mask) - (P-1)*Exp_msk1; 46112158Sdas#ifndef Sudden_Underflow 47112158Sdas if (L > 0) { 48112158Sdas#endif 49112158Sdas#ifdef IBM 50112158Sdas L |= Exp_msk1 >> 4; 51112158Sdas#endif 52219557Sdas word0(&a) = L; 53219557Sdas word1(&a) = 0; 54112158Sdas#ifndef Sudden_Underflow 55112158Sdas } 56112158Sdas else { 57112158Sdas L = -L >> Exp_shift; 58112158Sdas if (L < Exp_shift) { 59219557Sdas word0(&a) = 0x80000 >> L; 60219557Sdas word1(&a) = 0; 61112158Sdas } 62112158Sdas else { 63219557Sdas word0(&a) = 0; 64112158Sdas L -= Exp_shift; 65219557Sdas word1(&a) = L >= 31 ? 1 : 1 << (31 - L); 66112158Sdas } 67112158Sdas } 68112158Sdas#endif 69219557Sdas return dval(&a); 70112158Sdas } 71