From: Peter Vandenabeele Date: 2012-01-29T03:43:22+09:00 Subject: Re: Microrant on Ruy's Math Skills --20cf3033497366d83f04b79afbcd Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Fri, Jan 27, 2012 at 8:51 AM, Matthias W=C3=A4chter wrote: > Am 25.01.2012 15:28, schrieb botp: > >> 2012/1/25 Matthias W=C3=A4chter >> >: >> >>> I=E2=80=99m curious to see what=E2=80=99s gonna happen once Desktop CPU= s start to support >>> the nice decimal floating-point types of IEEE 754-2008 >>> [http://en.wikipedia.org/wiki/**IEEE_754-2008#Basic_formats] >>> =E2=80=A6 maybe Ruby >>> should already prepare syntactically for support of these types. And, i= n >>> theory, there is already a library from Intel >>> [http://software.intel.com/en-**us/articles/intel-decimal-** >>> floating-point-math-library/ >>> ] >>> one can use to do decimal floating-point math. >>> >> >> wow, thanks for the update. i hope ruby can indeed support that even >> if i need to recompile manually. >> > If I understand correctly, the IEEE 754-2008 decimal formats are fixed size= , so even the largest of them (128 bit) http://en.wikipedia.org/wiki/Decimal128_floating-point_format is fixed size limited to 34 digits. But the current Ruby BigDecimal implementation can go well beyond that: $ ruby -v ruby 1.9.3p0 (2011-10-30 revision 33570) [i686-linux] 002:0> require 'bigdecimal' =3D> true 003:0> require 'bigdecimal/util' =3D> true 005:0> a =3D BigDecimal.new("12345678901234567890123456789012345678901234567890123456789= 0") =3D> # 006:0> b =3D a +1 =3D> # 007:0> b - a =3D> # 008:0> (b - a).to_s =3D> "0.1E1" 009:0> (b - a).to_s('F') =3D> "1.0" That means to remain truely backwards compatible, we would need something like: 1.1 #=3D> Float (machine dependent) 1.1BD #=3D> BigDecimal ("unlimited" size) 1.1D #=3D> Decimal (e.g. picking the standardized IEEE 754 2008 Decimal128 fomat) HTH, Peter --20cf3033497366d83f04b79afbcd--