From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from conssluserg-06.nifty.com (conssluserg-06.nifty.com [210.131.2.91]) by sourceware.org (Postfix) with ESMTPS id 2D06E3858D28 for ; Thu, 2 Dec 2021 09:50:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2D06E3858D28 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=nifty.ne.jp Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=nifty.ne.jp Received: from Express5800-S70 (z221123.dynamic.ppp.asahi-net.or.jp [110.4.221.123]) (authenticated) by conssluserg-06.nifty.com with ESMTP id 1B29oHje002550 for ; Thu, 2 Dec 2021 18:50:17 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-06.nifty.com 1B29oHje002550 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.ne.jp; s=dec2015msa; t=1638438617; bh=bNdd88uZO0R9tBcn7zK5p2ky0Cssx+ZTY6oqW/PfHRs=; h=Date:From:To:Subject:In-Reply-To:References:From; b=gB0wqbA+L6YHwcwCR02uqiDVHlgnRK9DUc5aj8Gi0++3vYk3a6SgB3AGWREtIkgWN yMT66Y86T/XQZug6PEO3uftLIp/L5e0lkrL9JU28KG9H/nt1Pdee9toArUVRPwbmlr jW96wVFRoZei+vhmRQi8JkAoqkbq6VJvOIzKl1aY9V997s5IyiUJEYHezRt/6MDH9W h230vbL3W4KMZNBQaZKIyl9CS0oefpu2f4yrOJQ4djsQFGG5RLndDZuBPcLQ/X1nov SxAzGq2iT+Bo5rRd08AvY1Px7bdB1fBdO4cm+ZipSkPMFWe8OfhuOxr90u45dPN4kX n1NmgC9euAkEg== X-Nifty-SrcIP: [110.4.221.123] Date: Thu, 2 Dec 2021 18:50:18 +0900 From: Takashi Yano To: newlib@sourceware.org Subject: Re: [PATCH] frexpl: Support smaller long double. Message-Id: <20211202185018.96b29d1060a05dfbdf078b60@nifty.ne.jp> In-Reply-To: References: X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Dec 2021 09:50:38 -0000 On Thu, 02 Dec 2021 09:07:43 +0100 Paul Zimmermann wrote: > about https://sourceware.org/pipermail/newlib/2021/018738.html: > > > This patch add support for smaller long double, LDBL_MANT_DIG is 24 or 53. > > are you sure LDBL_MANT_DIG can be 24 in radix 2? As far as I know, the standard > requires LDBL_DIG >= 10, and a floating-point number with LDBL_DIG decimal > digits should be converted to a long double and back to LDBL_DIG digits > without any modification, which requires LDBL_MANT_DIG >= 34. > > Also the standard says in 6.2.5: "the set of values of the > type double is a subset of the set of values of the type long double." Thanks for pointing out this. I now have read ISO/IEC9899 standard draft, and confirm that it requires LDBL_DIG >= 10. It also says DBL_DIG >= 10. If this means LDBL_MANT_DIG and DBL_MANT_DIG >= 34, double also should not be DBL_MANT_DIG == 24. However, newlib supports _DOUBLE_IS_32BITS. I guess some platfors does not comply with the standard. So I consider long double can be smaller in such platforms. However if both double and long double are 32bit, frexpl() calls frexp() (double version). So this patch does more than necessary. I will submit v2 patch, which removes following LDBM_MANT_DIG == 24 case. +# if (LDBL_MANT_DIG == 24) /* 32-bit long double */ +static const double scale = 0x1p25; + +union ldbl { + long double x; + struct { +# ifdef __IEEE_LITTLE_ENDIAN /* for Intel CPU */ + __uint32_t frac:23; + __uint32_t exp:8; + __uint32_t sign:1; +# endif +# ifdef __IEEE_BIG_ENDIAN +# ifndef ___IEEE_BYTES_LITTLE_ENDIAN + __uint32_t sign:1; + __uint32_t exp:8; + __uint32_t frac:23; +# else /* ARMEL without __VFP_FP__ */ + __uint32_t frac:23; + __uint32_t exp:8; + __uint32_t sign:1; +# endif +# endif + } u32; +}; -- Takashi Yano