Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: Pedro Alves <palves@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Implement floordiv operator for gdb.Value
Date: Tue, 20 Sep 2016 16:42:00 -0000	[thread overview]
Message-ID: <20160920164140.GC5736@redhat.com> (raw)
In-Reply-To: <20160920163556.GB5736@redhat.com>

On 20/09/16 17:35 +0100, Jonathan Wakely wrote:
>On 20/09/16 16:33 +0100, Pedro Alves wrote:
>>>@@ -1142,7 +1160,15 @@ valpy_binop_throw (enum valpy_opcode opcode, PyObject *self, PyObject *other)
>>>     }
>>>
>>>   if (res_val)
>>>-    result = value_to_value_object (res_val);
>>>+    {
>>>+      if (floor_it)
>>>+        {
>>>+          double d = value_as_double (res_val);
>>
>>Should be s/double/DOUBLEST, I suppose?
>
>OK - if I do that then floor(d) will convert it back to double,
>unless you #include <cmath> and using std::floor, so that the overload
>for long double is visible (in C++ <math.h> names like floor are
>overloaded so you don't need to use floorf/floor/floorl according to
>the type).

P.S. In theory it should work with <math.h> and without the
using-declaration, but with GCC that wasn't true until GCC 6.1 (see
http://developerblog.redhat.com/2016/02/29/why-cstdlib-is-more-complicated-than-you-might-think/
for the gory details).

So to get the right result for older versions of GCC you need <cmath>.



  reply	other threads:[~2016-09-20 16:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-20 13:34 Jonathan Wakely
2016-09-20 14:46 ` Jonathan Wakely
2016-09-20 15:41 ` Pedro Alves
2016-09-20 16:41   ` Jonathan Wakely
2016-09-20 16:42     ` Jonathan Wakely [this message]
2016-09-20 17:01     ` Pedro Alves
2016-09-20 17:11       ` Jonathan Wakely
2016-09-20 17:08     ` Paul.Koning
2016-09-20 18:20       ` Jonathan Wakely
2016-09-20 19:06         ` Paul.Koning

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=20160920164140.GC5736@redhat.com \
    --to=jwakely@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    /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