153438Sbostic /*- 253438Sbostic * Copyright (c) 1992 The Regents of the University of California. 353438Sbostic * All rights reserved. 453438Sbostic * 553438Sbostic * %sccs.include.redist.c% 653438Sbostic */ 753438Sbostic 853438Sbostic #if defined(LIBC_SCCS) && !defined(lint) 9*53459Sbostic static char sccsid[] = "@(#)floatdidf.c 5.2 (Berkeley) 05/12/92"; 1053438Sbostic #endif /* LIBC_SCCS and not lint */ 1153438Sbostic 12*53459Sbostic /* Copyright (C) 1989, 1992 Free Software Foundation, Inc. 13*53459Sbostic 14*53459Sbostic This file is part of GNU CC. 15*53459Sbostic 16*53459Sbostic GNU CC is free software; you can redistribute it and/or modify 17*53459Sbostic it under the terms of the GNU General Public License as published by 18*53459Sbostic the Free Software Foundation; either version 2, or (at your option) 19*53459Sbostic any later version. 20*53459Sbostic 21*53459Sbostic GNU CC is distributed in the hope that it will be useful, 22*53459Sbostic but WITHOUT ANY WARRANTY; without even the implied warranty of 23*53459Sbostic MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24*53459Sbostic GNU General Public License for more details. 25*53459Sbostic 26*53459Sbostic You should have received a copy of the GNU General Public License 27*53459Sbostic along with GNU CC; see the file COPYING. If not, write to 28*53459Sbostic the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ 29*53459Sbostic 30*53459Sbostic /* As a special exception, if you link this library with files 31*53459Sbostic compiled with GCC to produce an executable, this does not cause 32*53459Sbostic the resulting executable to be covered by the GNU General Public License. 33*53459Sbostic This exception does not however invalidate any other reasons why 34*53459Sbostic the executable file might be covered by the GNU General Public License. */ 35*53459Sbostic 3653438Sbostic #include "longlong.h" 3753438Sbostic 3853438Sbostic #define HIGH_HALFWORD_COEFF (((long long) 1) << (BITS_PER_WORD / 2)) 3953438Sbostic #define HIGH_WORD_COEFF (((long long) 1) << BITS_PER_WORD) 4053438Sbostic 4153438Sbostic double 4253438Sbostic __floatdidf (u) 4353438Sbostic long long u; 4453438Sbostic { 4553438Sbostic double d; 4653438Sbostic int negate = 0; 4753438Sbostic 4853438Sbostic if (u < 0) 4953438Sbostic u = -u, negate = 1; 5053438Sbostic 5153438Sbostic d = (unsigned int) (u >> BITS_PER_WORD); 5253438Sbostic d *= HIGH_HALFWORD_COEFF; 5353438Sbostic d *= HIGH_HALFWORD_COEFF; 5453438Sbostic d += (unsigned int) (u & (HIGH_WORD_COEFF - 1)); 5553438Sbostic 5653438Sbostic return (negate ? -d : d); 5753438Sbostic } 58