Path: 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 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 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