1 /*- 2 * Copyright (c) 1992 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * This software was developed by the Computer Systems Engineering group 6 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 7 * contributed to Berkeley. 8 * 9 * %sccs.include.redist.c% 10 */ 11 12 #if defined(LIBC_SCCS) && !defined(lint) 13 static char sccsid[] = "@(#)fixsfdi.c 5.1 (Berkeley) 07/07/92"; 14 #endif /* LIBC_SCCS and not lint */ 15 16 #include "quad.h" 17 18 /* 19 * Convert float to (signed) quad. 20 * We clamp anything that is out of range. 21 * 22 * N.B.: must use new ANSI syntax (sorry). 23 */ 24 long long 25 __fixsfdi(float x) 26 { 27 if (x < 0) 28 if (x <= QUAD_MIN) 29 return (QUAD_MIN); 30 else 31 return ((quad_t)-(u_quad_t)-x); 32 else 33 if (x >= QUAD_MAX) 34 return (QUAD_MAX); 35 else 36 return ((quad_t)(u_quad_t)x); 37 } 38