--20cf3033497366d83f04b79afbcd Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Fri, Jan 27, 2012 at 8:51 AM, Matthias Wächter <matthias / waechter.wiz.at>wrote: > Am 25.01.2012 15:28, schrieb botp: > >> 2012/1/25 Matthias Wächter<matthias / waechter.wiz.**at<matthias / waechter.wiz.at> >> >: >> >>> I curious to see what gonna happen once Desktop CPUs start to support >>> the nice decimal floating-point types of IEEE 754-2008 >>> [http://en.wikipedia.org/wiki/**IEEE_754-2008#Basic_formats<http://en.wikipedia.org/wiki/IEEE_754-2008#Basic_formats>] >>> maybe Ruby >>> should already prepare syntactically for support of these types. And, in >>> theory, there is already a library from Intel >>> [http://software.intel.com/en-**us/articles/intel-decimal-** >>> floating-point-math-library/<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' => true 003:0> require 'bigdecimal/util' => true 005:0> a = BigDecimal.new("123456789012345678901234567890123456789012345678901234567890") => #<BigDecimal:985aa30,'0.1234567890 1234567890 1234567890 1234567890 1234567890 123456789E60',63(72)> 006:0> b = a +1 => #<BigDecimal:9859324,'0.1234567890 1234567890 1234567890 1234567890 1234567890 1234567891E60',63(144)> 007:0> b - a => #<BigDecimal:98639a0,'0.1E1',9(81)> 008:0> (b - a).to_s => "0.1E1" 009:0> (b - a).to_s('F') => "1.0" That means to remain truely backwards compatible, we would need something like: 1.1 #=> Float (machine dependent) 1.1BD #=> BigDecimal ("unlimited" size) 1.1D #=> Decimal (e.g. picking the standardized IEEE 754 2008 Decimal128 fomat) HTH, Peter --20cf3033497366d83f04b79afbcd--