unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* asserting the equality of double values
@ 2007-09-15 17:53 Kamaraju S Kusumanchi
  2007-09-15 19:20 ` Nelson H. F. Beebe
  2007-09-17 17:45 ` Stephen Compall
  0 siblings, 2 replies; 6+ messages in thread
From: Kamaraju S Kusumanchi @ 2007-09-15 17:53 UTC (permalink / raw)
  To: guile-devel

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-09-18  2:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-15 17:53 asserting the equality of double values Kamaraju S Kusumanchi
2007-09-15 19:20 ` 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

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).