From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 104530 invoked by alias); 20 Sep 2016 17:01:27 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 104239 invoked by uid 89); 20 Sep 2016 17:01:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1239, Nov, nov X-HELO: esa3.dell-outbound.iphmx.com Received: from Unknown (HELO esa3.dell-outbound.iphmx.com) (68.232.153.94) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 20 Sep 2016 17:01:25 +0000 Received: from esa1.dell-outbound2.iphmx.com ([68.232.153.201]) by esa3.dell-outbound.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Sep 2016 12:01:12 -0500 From: Received: from ausc60pc101.us.dell.com ([143.166.85.206]) by esa1.dell-outbound2.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Sep 2016 23:01:12 +0600 X-LoopCount0: from 10.170.28.40 To: CC: , Subject: Re: [PATCH] Implement floordiv operator for gdb.Value Date: Tue, 20 Sep 2016 17:08:00 -0000 Message-ID: <1196FC25-F9EC-4A16-B675-19AA200E7B94@dell.com> References: <20160920132633.GA897@redhat.com> <883c76d5-54e9-e8fe-5713-eec2c4010498@redhat.com> <20160920163556.GB5736@redhat.com> In-Reply-To: <20160920163556.GB5736@redhat.com> Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-SW-Source: 2016-09/txt/msg00233.txt.bz2 > On Sep 20, 2016, at 12:35 PM, Jonathan Wakely wrote: >=20 >> ... >=20 > 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: >=20 > (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)=20 [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)=20 [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)=20 [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 >>>=20 paul