From: erik quanstrom <quanstro@labs.coraid.com>
To: fausto.saporito@gmail.com, quanstro@quanstro.net, 9fans@9fans.net
Subject: Re: [9fans] f2c issue
Date: Fri, 22 Nov 2013 14:54:29 -0500 [thread overview]
Message-ID: <390a9731e0c3f617cdfcdf3bd7ee81cb@coraid.com> (raw)
In-Reply-To: <CAF1zXhm95ew=kTNDUeJvLuPV7CusEW+D+p2pHcAFuqx6w=16GA@mail.gmail.com>
> get_nanbits(unsigned int *b, int k)
> {
> union { double d; unsigned int z[2]; } u, u1, u2;
>
> k = 2 - k;
> u1.z[k] = u2.z[k] = 0x7ff00000;
> u1.z[1-k] = u2.z[1-k] = 0;
> u.d = u1.d - u2.d; /* Infinity - Infinity */ <<<<<<<====== this is the
> FATAL ERROR.
> b[0] = u.z[0];
> b[1] = u.z[1];
> }
>
> called as getnanbits(nanbits,1)
oh, boy.
we can assume ieee 754. the pattern you want for the nan is
u.hi = 0x7ff80000; /* sign = 0; exp = 1s; msb in signf set */
u.lo = 0;
you can use FPdbleword in <u.h> for regular plan 9 programs,
and <float.h> for ape programs which will take care of this for you.
in that case, you'd have
void
get_nanbits(unsigned int *b, int)
{
FPdbleword w;
assert(sizeof(double) == 8);
w.hi = 0x7ff80000;
w.lo = 0;
memcpy(b, &w, 8);
}
next prev parent reply other threads:[~2013-11-22 19:54 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-21 16:50 Fausto Saporito
2013-11-21 17:20 ` Jens Staal
2013-11-21 21:37 ` Fausto Saporito
2013-11-22 8:18 ` Jens Staal
2013-11-22 12:14 ` Fausto Saporito
2013-11-22 14:44 ` erik quanstrom
2013-11-22 16:42 ` Fausto Saporito
2013-11-22 16:52 ` Federico G. Benavento
2013-11-22 19:54 ` erik quanstrom [this message]
2013-11-22 21:18 ` Fausto Saporito
2013-11-22 22:15 ` Charles Forsyth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=390a9731e0c3f617cdfcdf3bd7ee81cb@coraid.com \
--to=quanstro@labs.coraid.com \
--cc=9fans@9fans.net \
--cc=fausto.saporito@gmail.com \
--cc=quanstro@quanstro.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).