From owner-freebsd-numerics@FreeBSD.ORG Thu Oct 31 21:38:36 2013 Return-Path: Delivered-To: freebsd-numerics@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id DA869C95 for ; Thu, 31 Oct 2013 21:38:36 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail109.syd.optusnet.com.au (mail109.syd.optusnet.com.au [211.29.132.80]) by mx1.freebsd.org (Postfix) with ESMTP id 9A2DB2550 for ; Thu, 31 Oct 2013 21:38:36 +0000 (UTC) Received: from c122-106-156-23.carlnfd1.nsw.optusnet.com.au (c122-106-156-23.carlnfd1.nsw.optusnet.com.au [122.106.156.23]) by mail109.syd.optusnet.com.au (Postfix) with ESMTPS id 3876DD615E5; Fri, 1 Nov 2013 08:38:33 +1100 (EST) Date: Fri, 1 Nov 2013 08:38:32 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Steve Kargl Subject: Re: Representation of 128 bit floating point numbers in FreeBSD amd64 and Clang In-Reply-To: <20131031143832.GA60432@troutmask.apl.washington.edu> Message-ID: <20131101075253.D1002@besplex.bde.org> References: <20131031143832.GA60432@troutmask.apl.washington.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=DstvpgP+ c=1 sm=1 tr=0 a=ebeQFi2P/qHVC0Yw9JDJ4g==:117 a=PO7r1zJSAAAA:8 a=XcIAvh7vBXYA:10 a=kj9zAlcOel0A:10 a=JzwRw_2MAAAA:8 a=m1xzMb9Q4KEA:10 a=gvndaTeijtoiqymt6GsA:9 a=LttEI1DeLjFl7mtf:21 a=vk93HtXyWNy8f4WY:21 a=CjuIK1q_8ugA:10 Cc: freebsd-numerics@FreeBSD.org X-BeenThere: freebsd-numerics@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Discussions of high quality implementation of libm functions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Oct 2013 21:38:36 -0000 On Thu, 31 Oct 2013, Steve Kargl wrote: > On Thu, Oct 31, 2013 at 09:27:34AM -0400, Mehmet Erol Sanliturk wrote: >> >> In FreeBSD amd64 and Clang , >> how can I represent 128 bits ( 34 digits ) variables ? With difficulty, since it is not supported. > Not sure it can be done with clang, but GCC supports > a __float128 type. GCC refers to this as its TCmode. > gfortran, the Fortran compiler that supports REAL(16), > uses __float128 internally. I've never directly used > __float128, so can't help beyond this. > > If you need 128-bits in C on ia32 or x86_64 hardware, > you should probably look into using mpfr and mpc. Even gcc-4.2.1 in FreeBSD generates code to use __float128, but the support for it isn't compiled into libgcc for some reason. Why would anyone want to use 128-bit FP on x86? It is emulated similarly to on sparc64. On sparc64, emulated 128-bit FP is about 100 times slower than hardware 64-bit FP. The emulation is not very good, but 128-bit FP is part of the ABI on sparc64 so I would expect the emulation to give an even larger slowdown factor in x86. With 80-bit FP, you can't quite exactly count the number of atoms in the universe, but you can count the world's GNP in cents for a thousand years or so. Extra accuracy can reduce problems from numerica instability and rounding bugs, but a slowdown factor of 100 times is a large price to pay for that. Bruce