unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* -0.0 treated as negative?
@ 2010-06-07 14:00 Bill Schottstaedt
  2010-06-07 21:28 ` Andy Wingo
  0 siblings, 1 reply; 5+ messages in thread
From: Bill Schottstaedt @ 2010-06-07 14:00 UTC (permalink / raw)
  To: bug-guile

I just noticed a case where -0.0 is apparently negative:

scheme@(guile-user)> (/ 1.0 0.0)
+inf.0
scheme@(guile-user)> (/ -1.0 0.0)
-inf.0
scheme@(guile-user)> (/ 1.0 -0.0)   
-inf.0
scheme@(guile-user)> (/ -1.0 -0.0)
+inf.0
scheme@(guile-user)> (negative? -0.0)
#f

And here's a separate oddity:

scheme@(guile-user)> (expt #t 0)
1




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

* Re: -0.0 treated as negative?
  2010-06-07 14:00 -0.0 treated as negative? Bill Schottstaedt
@ 2010-06-07 21:28 ` Andy Wingo
  2010-06-08 11:32   ` Bill Schottstaedt
  2010-06-08 11:51   ` Bill Schottstaedt
  0 siblings, 2 replies; 5+ messages in thread
From: Andy Wingo @ 2010-06-07 21:28 UTC (permalink / raw)
  To: Bill Schottstaedt; +Cc: bug-guile

Hi Bill,

On Mon 07 Jun 2010 16:00, "Bill Schottstaedt" <bil@ccrma.Stanford.EDU> writes:

> I just noticed a case where -0.0 is apparently negative:
>
> scheme@(guile-user)> (/ 1.0 -0.0)   
> -inf.0
> scheme@(guile-user)> (negative? -0.0)
> #f

Interesting. R5RS seems to be mute on negative zeros. The behavior of
negative? is correct according to R6RS, and the result (/ 1.0 -0.0)
follows IEEE 754, I think; so while odd, it does not seem to be a bug.
Let me know if I'm missing something here.

> scheme@(guile-user)> (expt #t 0)
> 1

Haha, that's amusing :) Will fix. 

Andy
-- 
http://wingolog.org/



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

* Re: -0.0 treated as negative?
@ 2010-06-08  9:49 Bill Schottstaedt
  0 siblings, 0 replies; 5+ messages in thread
From: Bill Schottstaedt @ 2010-06-08  9:49 UTC (permalink / raw)
  To: bug-guile

> Let me know if I'm missing something here.

Independent of standards, it means your arithmetic is inconsistent:

scheme@(guile-user)> (= -0.0 0.0)
#t
scheme@(guile-user)> (= +inf.0 +inf.0)
#t
scheme@(guile-user)> (= 1.0 1.0)
#t
scheme@(guile-user)> (= (/ 1.0 0.0) +inf.0)
#t
scheme@(guile-user)> (= (/ 1.0 0.0) (/ 1.0 -0.0))
#f




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

* Re: -0.0 treated as negative?
  2010-06-07 21:28 ` Andy Wingo
@ 2010-06-08 11:32   ` Bill Schottstaedt
  2010-06-08 11:51   ` Bill Schottstaedt
  1 sibling, 0 replies; 5+ messages in thread
From: Bill Schottstaedt @ 2010-06-08 11:32 UTC (permalink / raw)
  To: bug-guile

Here's a slightly better example:

scheme@(guile-user)> (< (/ 1.0 -0.0) -1e100 1e100 (/ 1.0 0.0))
#t





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

* Re: -0.0 treated as negative?
  2010-06-07 21:28 ` Andy Wingo
  2010-06-08 11:32   ` Bill Schottstaedt
@ 2010-06-08 11:51   ` Bill Schottstaedt
  1 sibling, 0 replies; 5+ messages in thread
From: Bill Schottstaedt @ 2010-06-08 11:51 UTC (permalink / raw)
  To: Andy Wingo; +Cc: bug-guile

I find this issue has been discussed elsewhere and:

"However, the IEEE committee decided that the advantages of utilizing the sign of zero outweighed the 
disadvantages."

humph.  Another committee covers itself with glory.




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

end of thread, other threads:[~2010-06-08 11:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-07 14:00 -0.0 treated as negative? Bill Schottstaedt
2010-06-07 21:28 ` Andy Wingo
2010-06-08 11:32   ` Bill Schottstaedt
2010-06-08 11:51   ` Bill Schottstaedt
  -- strict thread matches above, loose matches on Subject: below --
2010-06-08  9:49 Bill Schottstaedt

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