unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#5916: XFLOAT_DATA and signed zeroes
@ 2010-04-09 23:39 Vincent Lefevre
  2010-04-10 15:20 ` Stefan Monnier
  2010-05-16 18:58 ` Glenn Morris
  0 siblings, 2 replies; 8+ messages in thread
From: Vincent Lefevre @ 2010-04-09 23:39 UTC (permalink / raw)
  To: 5916

Hi,

I don't know whether there's really a bug (I haven't tested the
trunk), but someone pointed a suspicious macro[*]. The change
(on 2009-08-17) is here:

http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=6f0c16bc45815337d520a9393f8de5f9c14a06d4

It is said:

  lisp.h (XFLOAT_DATA): Produce an rvalue by adding 0 to the value.

However, adding 0 has another side effect on floats: the 0 is
converted into +0.0 (due to the addition with a double), so that
a -0.0 is transformed into a +0.0.

Could someone try the following?

  (/ 1.0 (- 0.0))

The correct result should be -1.0e+INF (negative infinity).

[*] http://groupes.codes-sources.com/article-emacs-lisp-sera-iee754-fut-0x-p0-toujours-470516.aspx

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)







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

* bug#5916: XFLOAT_DATA and signed zeroes
  2010-04-09 23:39 bug#5916: XFLOAT_DATA and signed zeroes Vincent Lefevre
@ 2010-04-10 15:20 ` Stefan Monnier
  2010-04-10 16:05   ` Andreas Schwab
  2010-05-16 18:58 ` Glenn Morris
  1 sibling, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2010-04-10 15:20 UTC (permalink / raw)
  To: Vincent Lefevre; +Cc: 5916

>   lisp.h (XFLOAT_DATA): Produce an rvalue by adding 0 to the value.

> However, adding 0 has another side effect on floats: the 0 is
> converted into +0.0 (due to the addition with a double), so that
> a -0.0 is transformed into a +0.0.

I guess we could/should make this "+0" conditional on some debugging
option, since after all it's only needed to catch coding errors.


        Stefan






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

* bug#5916: XFLOAT_DATA and signed zeroes
  2010-04-10 15:20 ` Stefan Monnier
@ 2010-04-10 16:05   ` Andreas Schwab
  2010-04-10 16:43     ` Vincent Lefevre
  0 siblings, 1 reply; 8+ messages in thread
From: Andreas Schwab @ 2010-04-10 16:05 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 5916, Vincent Lefevre

You can also use the unary + to create an rvalue.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."






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

* bug#5916: XFLOAT_DATA and signed zeroes
  2010-04-10 16:05   ` Andreas Schwab
@ 2010-04-10 16:43     ` Vincent Lefevre
  2010-04-10 17:25       ` Andreas Schwab
  0 siblings, 1 reply; 8+ messages in thread
From: Vincent Lefevre @ 2010-04-10 16:43 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: 5916

On 2010-04-10 18:05:24 +0200, Andreas Schwab wrote:
> You can also use the unary + to create an rvalue.

MPFR uses:

#define MPFR_VALUE_OF(x)  (0 ? (x) : (x))

It was suggested by Wojtek Lerch and Tim Rentsch in comp.std.c.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)






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

* bug#5916: XFLOAT_DATA and signed zeroes
  2010-04-10 16:43     ` Vincent Lefevre
@ 2010-04-10 17:25       ` Andreas Schwab
  0 siblings, 0 replies; 8+ messages in thread
From: Andreas Schwab @ 2010-04-10 17:25 UTC (permalink / raw)
  To: Vincent Lefevre; +Cc: 5916

Vincent Lefevre <vincent@vinc17.net> writes:

> MPFR uses:
>
> #define MPFR_VALUE_OF(x)  (0 ? (x) : (x))

You need that if you want to handle more than just arithmetic types.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."






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

* bug#5916: XFLOAT_DATA and signed zeroes
  2010-04-09 23:39 bug#5916: XFLOAT_DATA and signed zeroes Vincent Lefevre
  2010-04-10 15:20 ` Stefan Monnier
@ 2010-05-16 18:58 ` Glenn Morris
  2010-05-16 20:11   ` Ken Raeburn
  2010-05-16 20:12   ` Ken Raeburn
  1 sibling, 2 replies; 8+ messages in thread
From: Glenn Morris @ 2010-05-16 18:58 UTC (permalink / raw)
  To: raeburn; +Cc: 5916


> revno: 100306 [merge]
> committer: Ken Raeburn <raeburn@raeburn.org>
> branch nick: trunk
> timestamp: Sat 2010-05-15 17:21:30 -0400
[...]
>   * src/lisp.h (XFLOAT_DATA): Use "0?x:x" to generate an rvalue. (bug#5916)
>   (LISP_MAKE_RVALUE) [!USE_LISP_UNION_TYPE && !__GNUC__]: Likewise.


So can this bug be closed now?





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

* bug#5916: XFLOAT_DATA and signed zeroes
  2010-05-16 18:58 ` Glenn Morris
@ 2010-05-16 20:11   ` Ken Raeburn
  2010-05-16 20:12   ` Ken Raeburn
  1 sibling, 0 replies; 8+ messages in thread
From: Ken Raeburn @ 2010-05-16 20:11 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 5916

On May 16, 2010, at 14:58, Glenn Morris wrote:
> So can this bug be closed now?

Ah, yes... sorry, I forgot about that.  Thanks for the reminder.
Looking up how to do that now....

Ken





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

* bug#5916: XFLOAT_DATA and signed zeroes
  2010-05-16 18:58 ` Glenn Morris
  2010-05-16 20:11   ` Ken Raeburn
@ 2010-05-16 20:12   ` Ken Raeburn
  1 sibling, 0 replies; 8+ messages in thread
From: Ken Raeburn @ 2010-05-16 20:12 UTC (permalink / raw)
  To: 5916-done

Should be fixed on trunk by yesterday's checkin:

>> revno: 100306 [merge]
>> committer: Ken Raeburn <raeburn@raeburn.org>
>> branch nick: trunk
>> timestamp: Sat 2010-05-15 17:21:30 -0400
> [...]
>>  * src/lisp.h (XFLOAT_DATA): Use "0?x:x" to generate an rvalue. (bug#5916)
>>  (LISP_MAKE_RVALUE) [!USE_LISP_UNION_TYPE && !__GNUC__]: Likewise.






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

end of thread, other threads:[~2010-05-16 20:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-09 23:39 bug#5916: XFLOAT_DATA and signed zeroes Vincent Lefevre
2010-04-10 15:20 ` Stefan Monnier
2010-04-10 16:05   ` Andreas Schwab
2010-04-10 16:43     ` Vincent Lefevre
2010-04-10 17:25       ` Andreas Schwab
2010-05-16 18:58 ` Glenn Morris
2010-05-16 20:11   ` Ken Raeburn
2010-05-16 20:12   ` Ken Raeburn

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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