9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Charles Forsyth <forsyth@terzarima.net>
To: 9fans@9fans.net
Subject: Re: [9fans] compiler double bug.
Date: Tue,  1 Dec 2009 16:31:14 +0000	[thread overview]
Message-ID: <615bb2c21f211025b5d9aba799fffe0d@terzarima.net> (raw)
In-Reply-To: <aa38aea3812634942ec2e361c5552c87@brasstown.quanstro.net>

#include <u.h>
#include <libc.h>

void
main(void)
{
	double g = 4215866817.;

	print("%d\n", (unsigned int)g);
	print("%d\n", (unsigned int)g);
	exits("");
}
8c r.c
8l r.8
./8.out
-79100479
-79100479

no trap. it generates different code.
(obviously the %d should be %ud in this case, giving

doppio% 8.out
4215866817
4215866817

which looks like the right answer

the cast must be to an unsigned integer.
otherwise the resulting range is signed,
and that's more limited



  reply	other threads:[~2009-12-01 16:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <<9987774388a28369b01fa5658da35af9@terzarima.net>
2009-12-01 15:05 ` erik quanstrom
2009-12-01 16:31   ` Charles Forsyth [this message]
     [not found] <<d5e75e65219a1207aad92a000119dba0@terzarima.net>
2009-12-02  1:59 ` erik quanstrom
     [not found] <<d893fc0b1d0b52a1dd610d7eb14279d3@terzarima.net>
2009-12-01 22:31 ` erik quanstrom
2009-12-01 23:33   ` Charles Forsyth
     [not found] <<0232aa110f8423b8381e009b6cda7cef@terzarima.net>
2009-12-01 21:45 ` erik quanstrom
     [not found] <<dc10137c2661c11595d2aa2ca370ba45@brasstown.quanstro.net>
2009-12-01 18:53 ` erik quanstrom
     [not found] <<a4d2df97e4d97d460ae33ca0800a4060@terzarima.net>
2009-12-01 18:41 ` erik quanstrom
2009-12-01 21:35   ` Charles Forsyth
2009-12-01 22:19   ` Charles Forsyth
     [not found] <<615bb2c21f211025b5d9aba799fffe0d@terzarima.net>
2009-12-01 16:39 ` erik quanstrom
2009-12-01 17:02   ` Charles Forsyth
2009-12-01 16:39 ` erik quanstrom
     [not found] <<2d42b6b28807634253ba28dc55a96de6@brasstown.quanstro.net>
2009-12-01  8:02 ` erik quanstrom
2009-12-01  9:43   ` Charles Forsyth
2009-12-01  9:45     ` Charles Forsyth
2009-12-01  7:55 erik quanstrom

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=615bb2c21f211025b5d9aba799fffe0d@terzarima.net \
    --to=forsyth@terzarima.net \
    --cc=9fans@9fans.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).