fixunsdfdi.c (c6879c6c14eedbd060ba588a3129a6c60ebbe783) | fixunsdfdi.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[] = "@(#)fixunsdfdi.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[] = "@(#)fixunsdfdi.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 double to (unsigned) quad. 50 * Not sure what to do with negative numbers---for now, anything out 51 * of range becomes UQUAD_MAX. 52 */ --- 26 unchanged lines hidden (view full) --- 79 * range [0..ULONG_MAX]. For paranoia, we assume [LONG_MIN.. 80 * 2*ULONG_MAX] instead. 81 */ 82 t.ul[H] = (unsigned long)toppart; 83 t.ul[L] = 0; 84 x -= (double)t.uq; 85 if (x < 0) { 86 t.ul[H]--; | 45#define ONE_HALF (ONE_FOURTH * 2.0) 46#define ONE (ONE_FOURTH * 4.0) 47 48/* 49 * Convert double to (unsigned) quad. 50 * Not sure what to do with negative numbers---for now, anything out 51 * of range becomes UQUAD_MAX. 52 */ --- 26 unchanged lines hidden (view full) --- 79 * range [0..ULONG_MAX]. For paranoia, we assume [LONG_MIN.. 80 * 2*ULONG_MAX] instead. 81 */ 82 t.ul[H] = (unsigned long)toppart; 83 t.ul[L] = 0; 84 x -= (double)t.uq; 85 if (x < 0) { 86 t.ul[H]--; |
87 x += ULONG_MAX; | 87 x += (double)ULONG_MAX; |
88 } | 88 } |
89 if (x > ULONG_MAX) { | 89 if (x > (double)ULONG_MAX) { |
90 t.ul[H]++; | 90 t.ul[H]++; |
91 x -= ULONG_MAX; | 91 x -= (double)ULONG_MAX; |
92 } 93 t.ul[L] = (u_long)x; 94 return (t.uq); 95} | 92 } 93 t.ul[L] = (u_long)x; 94 return (t.uq); 95} |