Use ieee.h.
This commit is contained in:
parent
4ef547e76d
commit
291053e1e2
|
@ -1,8 +1,8 @@
|
|||
/* $NetBSD: frexp.c,v 1.3 1997/07/13 18:45:24 christos Exp $ */
|
||||
/* $NetBSD: frexp.c,v 1.4 1999/08/29 18:23:26 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
* Copyright (c) 1991 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -36,14 +36,14 @@
|
|||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)frexp.c 8.1 (Berkeley) 6/4/93";
|
||||
static char sccsid[] = "@(#)frexp.c 5.1 (Berkeley) 3/7/91";
|
||||
#else
|
||||
__RCSID("$NetBSD: frexp.c,v 1.3 1997/07/13 18:45:24 christos Exp $");
|
||||
__RCSID("$NetBSD: frexp.c,v 1.4 1999/08/29 18:23:26 mycroft Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <machine/endian.h>
|
||||
#include <machine/ieee.h>
|
||||
#include <math.h>
|
||||
|
||||
double
|
||||
|
@ -53,28 +53,16 @@ frexp(value, eptr)
|
|||
{
|
||||
union {
|
||||
double v;
|
||||
struct {
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
u_int u_mant2 : 32;
|
||||
u_int u_mant1 : 20;
|
||||
u_int u_exp : 11;
|
||||
u_int u_sign : 1;
|
||||
#else
|
||||
u_int u_sign : 1;
|
||||
u_int u_exp : 11;
|
||||
u_int u_mant1 : 20;
|
||||
u_int u_mant2 : 32;
|
||||
#endif
|
||||
} s;
|
||||
struct ieee_double s;
|
||||
} u;
|
||||
|
||||
if (value) {
|
||||
u.v = value;
|
||||
*eptr = u.s.u_exp - 1022;
|
||||
u.s.u_exp = 1022;
|
||||
return(u.v);
|
||||
*eptr = u.s.dbl_exp - (DBL_EXP_BIAS - 1);
|
||||
u.s.dbl_exp = DBL_EXP_BIAS - 1;
|
||||
return (u.v);
|
||||
} else {
|
||||
*eptr = 0;
|
||||
return((double)0);
|
||||
return (0.0);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue