1131852Sdas/*- 2131852Sdas * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG> 3131852Sdas * All rights reserved. 4131852Sdas * 5131852Sdas * Redistribution and use in source and binary forms, with or without 6131852Sdas * modification, are permitted provided that the following conditions 7131852Sdas * are met: 8131852Sdas * 1. Redistributions of source code must retain the above copyright 9131852Sdas * notice, this list of conditions and the following disclaimer. 10131852Sdas * 2. Redistributions in binary form must reproduce the above copyright 11131852Sdas * notice, this list of conditions and the following disclaimer in the 12131852Sdas * documentation and/or other materials provided with the distribution. 13131852Sdas * 14131852Sdas * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15131852Sdas * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16131852Sdas * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17131852Sdas * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18131852Sdas * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19131852Sdas * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20131852Sdas * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21131852Sdas * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22131852Sdas * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23131852Sdas * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24131852Sdas * SUCH DAMAGE. 25131852Sdas * 26131852Sdas * $FreeBSD: releng/10.2/lib/msun/src/s_isnormal.c 131852 2004-07-09 03:32:40Z das $ 27131852Sdas */ 28131852Sdas 29131852Sdas#include <math.h> 30131852Sdas 31131852Sdas#include "fpmath.h" 32131852Sdas 33131852Sdasint 34131852Sdas__isnormal(double d) 35131852Sdas{ 36131852Sdas union IEEEd2bits u; 37131852Sdas 38131852Sdas u.d = d; 39131852Sdas return (u.bits.exp != 0 && u.bits.exp != 2047); 40131852Sdas} 41131852Sdas 42131852Sdasint 43131852Sdas__isnormalf(float f) 44131852Sdas{ 45131852Sdas union IEEEf2bits u; 46131852Sdas 47131852Sdas u.f = f; 48131852Sdas return (u.bits.exp != 0 && u.bits.exp != 255); 49131852Sdas} 50131852Sdas 51131852Sdasint 52131852Sdas__isnormall(long double e) 53131852Sdas{ 54131852Sdas union IEEEl2bits u; 55131852Sdas 56131852Sdas u.e = e; 57131852Sdas return (u.bits.exp != 0 && u.bits.exp != 32767); 58131852Sdas} 59