From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 92621 invoked by alias); 9 Apr 2017 23:39:54 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 92612 invoked by uid 89); 9 Apr 2017 23:39:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-pg0-f52.google.com Received: from mail-pg0-f52.google.com (HELO mail-pg0-f52.google.com) (74.125.83.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 09 Apr 2017 23:39:52 +0000 Received: by mail-pg0-f52.google.com with SMTP id 81so96751463pgh.2 for ; Sun, 09 Apr 2017 16:39:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=pImDCKzsbvRxzML/CQeF5wkeSjBfd45s6hCEf4YpWK4=; b=uR+Jwe4LZ1sea5H2E3OIP8wtcPS1PqwRHc1+GRN2ouJWp6ySLLzuN2mjTbjO+aRwd2 599evfdFpOZGJXQtF770L0l87zM6JBJQLHwNGdaNIkzOsNrlsjUSg/zbDackF8Uvo8CL 7BqwPDQ3A/BmkPHCkp8LqKHNVy1QFJ2rHbysCdbzAGz/yP66i4olI0Sn09nvq4z/gAka huGG51qYMEMJIp1egizp/iiCcg8r5F4U/VZZW8zSjzg52LBWjS61ukQ8NJvlaM6bygtA HukF9w0NnhWQSWsKmYKWKO0GU7akBV6gy6sIajoz7Wgk0wIAFrqRhHjnWfCXzV8RI0vF t3IA== X-Gm-Message-State: AFeK/H0ZdlDshwDkm5gV1YlIm69vuBKy9vlv2OyM0KxRF6nJDSyU5/n6c7WbBmCwDo7QMw== X-Received: by 10.98.31.26 with SMTP id f26mr19992650pff.104.1491781192536; Sun, 09 Apr 2017 16:39:52 -0700 (PDT) Received: from bubble.grove.modra.org (CPE-58-160-71-80.tyqh2.lon.bigpond.net.au. [58.160.71.80]) by smtp.gmail.com with ESMTPSA id f5sm20759774pgn.50.2017.04.09.16.39.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Apr 2017 16:39:51 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id A51C6C073F; Mon, 10 Apr 2017 09:09:47 +0930 (ACST) Date: Sun, 09 Apr 2017 23:39:00 -0000 From: Alan Modra To: Pip Cet Cc: Nick Clifton , Simon Marchi , binutils@sourceware.org Subject: Re: [PATCH] [WebAssembly] Disassembler support Message-ID: <20170409233947.GA16711@bubble.grove.modra.org> References: <20170407220503.GX16711@bubble.grove.modra.org> <20170409103532.GZ16711@bubble.grove.modra.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes X-SW-Source: 2017-04/txt/msg00088.txt.bz2 On Sun, Apr 09, 2017 at 01:20:16PM +0000, Pip Cet wrote: > On Sun, Apr 9, 2017 at 10:35 AM, Alan Modra wrote: > > I think what I'd be inclined to do is print your WebAssembly floats > > and doubles in %a format. > > Wouldn't that also be a C99 thing? I know I looked into using %a and > decided it wasn't a good idea, probably for that reason. (Possibly, > also, because I personally find it hard to read, but that's less of a > concern). > > > You can probably do that without converting > > to host doubles. > > Well, I certainly would have to convert 32-bit floats to doubles > before calling printf... What I meant by %a format and not converting to host double is: - read 4-byte or 8-byte value - convert to host endian with bfd_get_32 or bfd_get_64 - extract sign, mantissa and exponent - decode special cases, nan, inf - print sign if negative, mantissa as hex, exponent as decimal to give [-]0xL.MMMMMMMMMMMMMp[+-]EEE (L being the leading implicit 1 or 0 if denormal, M mantissa, E exponent). See glibc/stdio_common/printf_fphex.c > > If that idea doesn't fly, just use a constant > > specific to your target floats and doubles, hoping the host is > > reasonably compatible. > > I think that's what my patch does, and I think it's the best thing to > do for now; should non-IEEE floats become significant again, > floatformat should probably provide its own printing functions. Yeah, I'm fine with your DECIMAL_DIG_IEEE754 patch, except to query whether you really want a precision of 17 for wasm_constant_f32, in which case forget the #define and use a hardcoded %.9g there and %.17g for wasm_constant_f64. Patch to do that preapproved. -- Alan Modra Australia Development Lab, IBM