1110566Smike/*- 2110566Smike * Copyright (c) 2003 Mike Barcroft <mike@FreeBSD.org> 3141379Sdas * Copyright (c) 2002 David Schultz <das@FreeBSD.ORG> 4110566Smike * All rights reserved. 5110566Smike * 6110566Smike * Redistribution and use in source and binary forms, with or without 7110566Smike * modification, are permitted provided that the following conditions 8110566Smike * are met: 9110566Smike * 1. Redistributions of source code must retain the above copyright 10110566Smike * notice, this list of conditions and the following disclaimer. 11110566Smike * 2. Redistributions in binary form must reproduce the above copyright 12110566Smike * notice, this list of conditions and the following disclaimer in the 13110566Smike * documentation and/or other materials provided with the distribution. 14110566Smike * 15110566Smike * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16110566Smike * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17110566Smike * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18110566Smike * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19110566Smike * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20110566Smike * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21110566Smike * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22110566Smike * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23110566Smike * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24110566Smike * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25110566Smike * SUCH DAMAGE. 26110566Smike * 27110566Smike * $FreeBSD$ 28110566Smike */ 29110566Smike 30110566Smike#include <sys/endian.h> 31110566Smike#include "_fpmath.h" 32110566Smike 33186461Smarcel#ifndef _IEEE_WORD_ORDER 34186461Smarcel#define _IEEE_WORD_ORDER _BYTE_ORDER 35186461Smarcel#endif 36186461Smarcel 37110566Smikeunion IEEEf2bits { 38110566Smike float f; 39110566Smike struct { 40110566Smike#if _BYTE_ORDER == _LITTLE_ENDIAN 41110566Smike unsigned int man :23; 42110566Smike unsigned int exp :8; 43110566Smike unsigned int sign :1; 44110566Smike#else /* _BIG_ENDIAN */ 45110566Smike unsigned int sign :1; 46110566Smike unsigned int exp :8; 47110566Smike unsigned int man :23; 48110566Smike#endif 49110566Smike } bits; 50110566Smike}; 51110566Smike 52124655Sdas#define DBL_MANH_SIZE 20 53124655Sdas#define DBL_MANL_SIZE 32 54124655Sdas 55110566Smikeunion IEEEd2bits { 56110566Smike double d; 57110566Smike struct { 58110566Smike#if _BYTE_ORDER == _LITTLE_ENDIAN 59186461Smarcel#if _IEEE_WORD_ORDER == _LITTLE_ENDIAN 60110566Smike unsigned int manl :32; 61186461Smarcel#endif 62110566Smike unsigned int manh :20; 63110566Smike unsigned int exp :11; 64110566Smike unsigned int sign :1; 65186461Smarcel#if _IEEE_WORD_ORDER == _BIG_ENDIAN 66186461Smarcel unsigned int manl :32; 67186461Smarcel#endif 68110566Smike#else /* _BIG_ENDIAN */ 69110566Smike unsigned int sign :1; 70110566Smike unsigned int exp :11; 71110566Smike unsigned int manh :20; 72110566Smike unsigned int manl :32; 73110566Smike#endif 74110566Smike } bits; 75110566Smike}; 76