From: Kamaraju S Kusumanchi <kamaraju@bluebottle.com>
To: guile-devel@gnu.org
Subject: asserting the equality of double values
Date: Sat, 15 Sep 2007 13:53:59 -0400 [thread overview]
Message-ID: <fch632$kbe$1@sea.gmane.org> (raw)
I was browsing the source code of guile 1.8.2 and have couple of trivial
questions. I would be very grateful if you can answer the following
questions.
1) In test-suite/standalone/test-round.c (lines 90-96) we have
/* 2^DBL_MANT_DIG-1
In the past scm_c_round had incorrectly incremented this value, due
to the way that x+0.5 would round upwards (in the usual default
nearest-even mode on most systems). */
x = ldexp (1.0, DBL_MANT_DIG) - 1.0;
assert (x == floor (x)); /* should be an integer already */
here ldexp and floor both return double values. Is it guaranteed that
asserting the equality of two double values will always work? When learning
C, I remember reading somewhere not to rely on such comparisons.
I also do not understand the comment /* should be an integer already */ at
the end of the line. AFAIK both ldexp, floor function return double values
and not integers. Can someone explain the comment?
I am interested in knowing this because guile 1.8.2 fails to build on a
Debian machine using alpha architecture. According to the build log of the
failure (
http://buildd.debian.org/fetch.cgi?&pkg=guile-1.8&ver=1.8.2%2B1-2&arch=alpha&stamp=1188100514&file=log )
it occurs around this part of the code.
2) The above code uses DBL_MANT_DIG macro. How can I easily find out where
this macro is defined? Is there any book or reference which discuss this
kind of macros. For now I did a grep in /usr/include and found that such a
macro is defined in /usr/include/c++/4.2/limits file. This brings up
another question.
If you are using a macro defined in a standard c++ library header, shouldn't
the file be named test-round.cpp instead of test-round.c?
thanks
raju
--
Kamaraju S Kusumanchi
http://www.people.cornell.edu/pages/kk288/
http://malayamaarutham.blogspot.com/
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
next reply other threads:[~2007-09-15 17:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-15 17:53 Kamaraju S Kusumanchi [this message]
2007-09-15 19:20 ` asserting the equality of double values Nelson H. F. Beebe
2007-09-18 0:13 ` Kevin Ryde
2007-09-18 2:44 ` Kamaraju S Kusumanchi
2007-09-17 17:45 ` Stephen Compall
2007-09-18 2:45 ` Kamaraju S Kusumanchi
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
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='fch632$kbe$1@sea.gmane.org' \
--to=kamaraju@bluebottle.com \
--cc=guile-devel@gnu.org \
/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 read-only IMAP folder(s) and NNTP newsgroup(s).