1*53438Sbostic /*- 2*53438Sbostic * Copyright (c) 1992 The Regents of the University of California. 3*53438Sbostic * All rights reserved. 4*53438Sbostic * 5*53438Sbostic * %sccs.include.redist.c% 6*53438Sbostic */ 7*53438Sbostic 8*53438Sbostic #if defined(LIBC_SCCS) && !defined(lint) 9*53438Sbostic static char sccsid[] = "@(#)floatdidf.c 5.1 (Berkeley) 05/12/92"; 10*53438Sbostic #endif /* LIBC_SCCS and not lint */ 11*53438Sbostic 12*53438Sbostic #include "longlong.h" 13*53438Sbostic 14*53438Sbostic #define HIGH_HALFWORD_COEFF (((long long) 1) << (BITS_PER_WORD / 2)) 15*53438Sbostic #define HIGH_WORD_COEFF (((long long) 1) << BITS_PER_WORD) 16*53438Sbostic 17*53438Sbostic double 18*53438Sbostic __floatdidf (u) 19*53438Sbostic long long u; 20*53438Sbostic { 21*53438Sbostic double d; 22*53438Sbostic int negate = 0; 23*53438Sbostic 24*53438Sbostic if (u < 0) 25*53438Sbostic u = -u, negate = 1; 26*53438Sbostic 27*53438Sbostic d = (unsigned int) (u >> BITS_PER_WORD); 28*53438Sbostic d *= HIGH_HALFWORD_COEFF; 29*53438Sbostic d *= HIGH_HALFWORD_COEFF; 30*53438Sbostic d += (unsigned int) (u & (HIGH_WORD_COEFF - 1)); 31*53438Sbostic 32*53438Sbostic return (negate ? -d : d); 33*53438Sbostic } 34