From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5849 invoked by alias); 14 Jun 2012 00:51:02 -0000 Received: (qmail 5822 invoked by uid 22791); 14 Jun 2012 00:51:01 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_HOSTKARMA_NO X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 14 Jun 2012 00:50:47 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 534331C669C for ; Wed, 13 Jun 2012 20:50:46 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id O+SoiWtjogP7 for ; Wed, 13 Jun 2012 20:50:46 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 243901C643F for ; Wed, 13 Jun 2012 20:50:46 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id D1C8F145616; Wed, 13 Jun 2012 17:50:43 -0700 (PDT) Date: Thu, 14 Jun 2012 00:51:00 -0000 From: Joel Brobecker To: gdb-patches@sourceware.org Subject: Re: [RFA] convert_doublest_to_floatformat: handle off-range values. Message-ID: <20120614005043.GJ18729@adacore.com> References: <1339632037-5252-1-git-send-email-brobecker@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1339632037-5252-1-git-send-email-brobecker@adacore.com> User-Agent: Mutt/1.5.20 (2009-06-14) 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 X-SW-Source: 2012-06/txt/msg00453.txt.bz2 > + if (exponent + fmt->exp_bias <= 0) > + { > + /* The value is too small to be expressed in the destination > + type (not enough bits in the exponent. Treat as 0. */ > + put_field (uto, order, fmt->totalsize, fmt->exp_start, > + fmt->exp_len, 0); > + put_field (uto, order, fmt->totalsize, fmt->man_start, > + fmt->man_len, 0); > + goto finalize_byteorder; > + } For these small numbers, we could do like libiberty, and generate denormalized numbers, like so: if (exponent + fmt->exp_bias - 1 > 0) put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start, fmt->exp_len, exponent + fmt->exp_bias - 1); else { /* Handle a denormalized number. FIXME: What should we do for non-IEEE formats? */ put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start, fmt->exp_len, 0); mant = ldexp (mant, exponent + fmt->exp_bias - 1); } But it'd be a larger change, because we'd have to write a portable version of ldexp that works for "long double". Actually, we could import ldexp and ldexpl. We should probably also consider the import of frexp and frexpl as well. It'd allow us to get rid of our own implementation. -- Joel