This is the mail archive of the
mailing list for the GDB project.
Re: [PATCH] Implement floordiv operator for gdb.Value
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)
- 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
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
for the gory details).
So to get the right result for older versions of GCC you need <cmath>.