From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 3C/SIU8Zq1/PGgAAWB0awg (envelope-from ) for ; Tue, 10 Nov 2020 17:50:55 -0500 Received: by simark.ca (Postfix, from userid 112) id 758901F08B; Tue, 10 Nov 2020 17:50:55 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id CEEAB1E58E for ; Tue, 10 Nov 2020 17:50:54 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 773B13857831; Tue, 10 Nov 2020 22:50:54 +0000 (GMT) Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id C49353857C75 for ; Tue, 10 Nov 2020 22:50:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C49353857C75 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark@simark.ca Received: from [10.0.0.11] (173-246-6-90.qc.cable.ebox.net [173.246.6.90]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 4BFBD1E58E; Tue, 10 Nov 2020 17:50:52 -0500 (EST) Subject: Re: [PATCH 6/9] fix printing of DWARF fixed-point type objects with format modifier To: Joel Brobecker , gdb-patches@sourceware.org References: <1604817017-25807-1-git-send-email-brobecker@adacore.com> <1604817017-25807-7-git-send-email-brobecker@adacore.com> From: Simon Marchi Message-ID: Date: Tue, 10 Nov 2020 17:50:51 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <1604817017-25807-7-git-send-email-brobecker@adacore.com> Content-Type: text/plain; charset=utf-8 Content-Language: fr Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" On 2020-11-08 1:30 a.m., Joel Brobecker wrote: > Consider a fixed-point type such the scaling factor is 1/16, > as the following Ada code snippet would create: > > type FP1_Type is delta 0.1 range -1.0 .. +1.0; > FP1_Var : FP1_Type := 0.25; > > Printing the value of this variable with a format modifier yields > the wrong value. E.g.: > > (gdb) p /x fp1_var > $6 = 0x4 > > Since the real value is 0.25, we therefore expected... > > (gdb) p /x fp1_var > $6 = 0x0 I find this behavior a bit strange and I wonder when this is useful. Intuitively, I would think that /x would give me the underlying representation, in hex, I think it is more likely to be useful. But I see that this is how floating points work: (gdb) ptype f type = float (gdb) p f $1 = 1.23000002 (gdb) p/x f $2 = 0x1 ... so it makes sense to have the same behavior for fixed points. Simon