🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.nsc.32k
Article #920

New frexp.c for libfp.a (Minix 1.5h)

#920
From: Sverre Froyen
Date: Fri, 10 May 1991 15:45
75 lines
2576 bytes
This ONLY applies to the libfp.a floating point library that
I sent out with my estdio diffs.  If you do not use this
library you can IGNORE this posting.

I finally got around to solving the problem with illegal
floating point constants in the assembly code from cc1.
It was caused by an oversight (mine) in frexp regarding
denormalized numbers.  Here is a new frexp.c which seems
to work.

-- 
Sverre Froyen
sverre@seri.gov, sunpeaks!seri!sverre

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  frexp.c
# Wrapped by sverre@lars on Fri May 10 09:43:15 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f frexp.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"frexp.c\"
else
echo shar: Extracting \"frexp.c\" \(751 characters\)
sed "s/^X//" >frexp.c <<'END_OF_frexp.c'
X/*
X * Return mantissa in range [0.5,1), store exponent.
X */
X
X#include "flt.h"
X
Xdouble
Xfrexp (double invalue, int *exp)
X{
X	_double value;
X	short sign;
X
X	value.d = invalue;
X
X	/* Extract and zero sign */
X	sign = value.s[S_MS] & SIGN_MASK;
X	value.s[S_MS] &= ~SIGN_MASK;
X
X	/* Check for zero exponent (no denormalized numbers) */
X	if ((value.s[S_MS] & EXP_MASK) == 0) {
X		value.l[L_MS] = 0L;
X		value.l[L_LS] = 0L;
X		*exp = 0;
X		value.s[S_MS] = sign;
X	}
X	else {
X		/* Extract exponent and subtract bias */
X		*exp = ((value.s[S_MS] & EXP_MASK) >> EXP_SHIFT) - (EXP_BIAS-1);
X
X		/* Set exponent to -1 (biased) */
X		value.s[S_MS] &= ~EXP_MASK;
X		value.s[S_MS] |= (EXP_BIAS-1) << EXP_SHIFT;
X
X		/* Restore sign */
X		value.s[S_MS] |= sign;
X	}
X	return value.d;    
X}
END_OF_frexp.c
if test 751 -ne `wc -c <frexp.c`; then
    echo shar: \"frexp.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of shell archive.
exit 0
Technical Details
Message-ID: <9105101545.AA02710@lars.seri.gov>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!swrinde!mips!daver!bungi.com!news

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!swrinde!mips!daver!bungi.com!news
From: sverre@lars.Seri.GOV (Sverre Froyen)
Newsgroups: comp.sys.nsc.32k
Subject: New frexp.c for libfp.a (Minix 1.5h)
Message-ID: <9105101545.AA02710@lars.seri.gov>
Date: 10 May 91 15:45:07 GMT
Sender: news@daver.bungi.com
Lines: 75
Approved: news@daver.bungi.com