fixunssfdi.c (82725ba9bf1fd59746a4006a06f24d4d61d142f2) | fixunssfdi.c (feb1d5507e4730fe401e6ae28a56579b814519ef) |
---|---|
1/*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright (c) 1992, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * This software was developed by the Computer Systems Engineering group 8 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and --- 27 unchanged lines hidden (view full) --- 36#if defined(LIBC_SCCS) && !defined(lint) 37static char sccsid[] = "@(#)fixunssfdi.c 8.1 (Berkeley) 6/4/93"; 38#endif /* LIBC_SCCS and not lint */ 39#include <sys/cdefs.h> 40__FBSDID("$FreeBSD$"); 41 42#include "quad.h" 43 | 1/*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright (c) 1992, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * This software was developed by the Computer Systems Engineering group 8 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and --- 27 unchanged lines hidden (view full) --- 36#if defined(LIBC_SCCS) && !defined(lint) 37static char sccsid[] = "@(#)fixunssfdi.c 8.1 (Berkeley) 6/4/93"; 38#endif /* LIBC_SCCS and not lint */ 39#include <sys/cdefs.h> 40__FBSDID("$FreeBSD$"); 41 42#include "quad.h" 43 |
44#define ONE_FOURTH (1 << (LONG_BITS - 2)) | 44#define ONE_FOURTH (1L << (LONG_BITS - 2)) |
45#define ONE_HALF (ONE_FOURTH * 2.0) 46#define ONE (ONE_FOURTH * 4.0) 47 48/* 49 * Convert float to (unsigned) quad. We do most of our work in double, 50 * out of sheer paranoia. 51 * 52 * Not sure what to do with negative numbers---for now, anything out --- 31 unchanged lines hidden (view full) --- 84 * range [0..ULONG_MAX]. For paranoia, we assume [LONG_MIN.. 85 * 2*ULONG_MAX] instead. 86 */ 87 t.ul[H] = (unsigned long)toppart; 88 t.ul[L] = 0; 89 x -= (double)t.uq; 90 if (x < 0) { 91 t.ul[H]--; | 45#define ONE_HALF (ONE_FOURTH * 2.0) 46#define ONE (ONE_FOURTH * 4.0) 47 48/* 49 * Convert float to (unsigned) quad. We do most of our work in double, 50 * out of sheer paranoia. 51 * 52 * Not sure what to do with negative numbers---for now, anything out --- 31 unchanged lines hidden (view full) --- 84 * range [0..ULONG_MAX]. For paranoia, we assume [LONG_MIN.. 85 * 2*ULONG_MAX] instead. 86 */ 87 t.ul[H] = (unsigned long)toppart; 88 t.ul[L] = 0; 89 x -= (double)t.uq; 90 if (x < 0) { 91 t.ul[H]--; |
92 x += ULONG_MAX; | 92 x += (double)ULONG_MAX; |
93 } | 93 } |
94 if (x > ULONG_MAX) { | 94 if (x > (double)ULONG_MAX) { |
95 t.ul[H]++; | 95 t.ul[H]++; |
96 x -= ULONG_MAX; | 96 x -= (double)ULONG_MAX; |
97 } 98 t.ul[L] = (u_long)x; 99 return (t.uq); 100} | 97 } 98 t.ul[L] = (u_long)x; 99 return (t.uq); 100} |