153436Sbostic /*- 253436Sbostic * Copyright (c) 1992 The Regents of the University of California. 353436Sbostic * All rights reserved. 453436Sbostic * 553794Sbostic * This software was developed by the Computer Systems Engineering group 653794Sbostic * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 753794Sbostic * contributed to Berkeley. 853794Sbostic * 953436Sbostic * %sccs.include.redist.c% 1053436Sbostic */ 1153436Sbostic 1253436Sbostic #if defined(LIBC_SCCS) && !defined(lint) 13*54431Sbostic static char sccsid[] = "@(#)fixdfdi.c 5.4 (Berkeley) 06/25/92"; 1453436Sbostic #endif /* LIBC_SCCS and not lint */ 1553436Sbostic 1653794Sbostic #include "quad.h" 1753459Sbostic 1853794Sbostic /* 1953794Sbostic * Convert double to (signed) quad. 2053794Sbostic * We clamp anything that is out of range. 2153794Sbostic */ 22*54431Sbostic quad_t 23*54431Sbostic __fixdfdi(x) 24*54431Sbostic double x; 2553436Sbostic { 2653794Sbostic if (x < 0) 2753794Sbostic if (x <= QUAD_MIN) 2853794Sbostic return (QUAD_MIN); 2953794Sbostic else 30*54431Sbostic return ((quad_t)-(u_quad_t)-x); 3153794Sbostic else 3253794Sbostic if (x >= QUAD_MAX) 3353794Sbostic return (QUAD_MAX); 3453794Sbostic else 35*54431Sbostic return ((quad_t)(u_quad_t)x); 3653436Sbostic } 37