Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: <Paul.Koning@dell.com>
To: <jwakely@redhat.com>
Cc: <palves@redhat.com>, <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Implement floordiv operator for gdb.Value
Date: Tue, 20 Sep 2016 17:08:00 -0000	[thread overview]
Message-ID: <1196FC25-F9EC-4A16-B675-19AA200E7B94@dell.com> (raw)
In-Reply-To: <20160920163556.GB5736@redhat.com>


> On Sep 20, 2016, at 12:35 PM, Jonathan Wakely <jwakely@redhat.com> wrote:
> 
>> ...
> 
> This seems to be an existing property of gdb.Value, as even using the
> normal division operator (and without my patch) I see floats printed
> without a decimal part when they are an integer value:
> 
> (gdb) python print (gdb.Value(5.0)/5.0)
> 1
> (gdb) python print (5.0/5.0)
> 1.0

In all this, please keep in mind that this is one place where Python 2 and Python 3 differ:

$ python
Python 2.7.6 (v2.7.6:3a1db0d2747e, Nov 10 2013, 00:42:54) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 1/2
0
>>> ^D
$ python3
Python 3.5.1 (v3.5.1:37a07cee5969, Dec  5 2015, 21:12:44) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 1/2
0.5
>>> ^D

Python 2 can be told to do it the new way:

$ python2
Python 2.7.6 (v2.7.6:3a1db0d2747e, Nov 10 2013, 00:42:54) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import division
>>> 1/2
0.5
>>> 

	paul


  parent reply	other threads:[~2016-09-20 17:01 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
2016-09-20 17:01     ` Pedro Alves
2016-09-20 17:11       ` Jonathan Wakely
2016-09-20 17:08     ` Paul.Koning [this message]
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=1196FC25-F9EC-4A16-B675-19AA200E7B94@dell.com \
    --to=paul.koning@dell.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jwakely@redhat.com \
    --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