www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - dec64 decimal floating point type

reply Alix Pexton <alix.DOT.pexton gmail.DOT.com> writes:
http://dec64.org/

I recently discovered this while watching a presentation by Doug 
Crockford on YouTube.

I know that Dlang is not in the category of languages that this new 
numeric representation is aimed at, but Dlang might well be used to 
implement a VM or compiler for one that is.

I think it is ripe for implementation along the same lines as half floats.

The reference implementation is on github (linked from the above) and is 
marked as public domain but porting the assembler (or rather the macros) 
non-trivial with my skill-set.

Anyone else convinced or opposed?

Anyone with more assembler-foo willing to lend a hand to the porting effort?

A...
Apr 12 2014
next sibling parent reply "Francesco Cattoglio" <francesco.cattoglio gmail.com> writes:
On Saturday, 12 April 2014 at 21:48:15 UTC, Alix Pexton wrote:
 http://dec64.org/

 I recently discovered this while watching a presentation by 
 Doug Crockford on YouTube.

 I know that Dlang is not in the category of languages that this 
 new numeric representation is aimed at, but Dlang might well be 
 used to implement a VM or compiler for one that is.

 I think it is ripe for implementation along the same lines as 
 half floats.

 The reference implementation is on github (linked from the 
 above) and is marked as public domain but porting the assembler 
 (or rather the macros) non-trivial with my skill-set.

 Anyone else convinced or opposed?

 Anyone with more assembler-foo willing to lend a hand to the 
 porting effort?

 A...

I don't quite see the point in this, when there is already a standard for floating point decimals http://en.wikipedia.org/wiki/Decimal64_floating-point_format I really should take a deeper look at this, it might be more interesting that I am expecting.
Apr 13 2014
parent reply Alix Pexton <alix.DOT.pexton gmail.DOT.com> writes:
On 13/04/2014 4:29 PM, Francesco Cattoglio wrote:

 I don't quite see the point in this, when there is already a standard
 for floating point decimals
 http://en.wikipedia.org/wiki/Decimal64_floating-point_format
 I really should take a deeper look at this, it might be more interesting
 that I am expecting.

The talk I watched only touched on the motivation for a new format very briefly, but the gist was that the existing offerings were too computationally expensive to emulate in software and hardware support is not forthcoming. My understanding is that this format is designed around what can be done efficiently with the instructions that are available in hardware today. A...
Apr 13 2014
parent reply Alix Pexton <alix.DOT.pexton gmail.DOT.com> writes:
On 14/04/2014 10:44 AM, Francesco Cattoglio wrote:

 This would make sense, at least partially, if hardware supporting the
 ieee was non-existant, but apparently hardware support for the decimal64
 standard is already here!

 Being a numerical analyst I can say I'm extremely interested when
 someone comes up with new interesting ideas, but as far as I can tell we
 still need to go down a long road before finding something better than
 good old floats. And I really think that one should stick to the
 standards, as long as the standard is good enough.

 On a side note, I think that support for decimal64 might be something
 nice to have in the D language, because apparently that one is the most
 used floating point type in the economic sectors.

I did a little research, you are right, IBM has implemented the IEEE decimal floats in their Power6 and z9 chips (since 2007), and Sparc64 chips have it too (since 2012). But the amount of silicon required to create these decimal FPUs is significantly greater than for binary FPUs (as the format is essentially a dense form of BCD) and this makes it very unlikely that they will ever make their way into desktop or mobile processors. The Dec64 decimal float is not a form of BCD, which is part of the reason why it can be emulated in software in a significantly more efficient way than the IEEE standard. While no hardware design exists, this would suggest that it would require less silicon, giving a greater chance that it will get into non-mainframe hardware. A while ago there was a proposal for a new decimal float format to be included in ECMAScript 4 but the resources for that proposal seem to have been purged ()I've only found a few broken links. But as Doug Crockford (who at least wrote the dec64 reference implementation if not conceived the whole design) is on the TC39 committee that works on the standards for ECMAScript, I assume that it is related to that proposal and might even become a part of ECMAscript standard in the future. Doug is a competent and respected programmer and speaker (among other things, he "discovered" JSON), and I believe that he would not have begun this project if there were not a compelling reason to do so. I hope that I am not misrepresenting him any way. I will endeavour to port the reference implementation solo as it will undoubtedly be educational, and also to find more evidence that the effort is worth my time! I'll gladly share both. A...
Apr 14 2014
parent Alix Pexton <alix.DOT.pexton gmail.DOT.com> writes:
I contacted Doug to ask if he had any additional resources that I could 
use to make my argument for DEC64. I only got a brief reply (happy to 
get any reply from someone so busy) to the effect that everything he has 
to say on the matter is in the motivation segment of his web site for 
the proposal [1].

The most salient part is the last 2 sentences...

	A later revision of IEEE 754 attempted to remedy this, but the
	formats it recommended were so inefficient that it has not
	found much acceptance. DEC64 is a better alternative.

I encourage anyone who is dismissive of the adoption of DEC64 or who would prefer to see the IEEE decimal floats implemented to take the time to read the full article. I also recommend the presentation that alerted me to DEC64 either in full (46:10) [2] or at least just the segment about numbers [3]. A... [1] http://dec64.org [2] https://www.youtube.com/watch?v=3WgVHE5Augc [3] https://www.youtube.com/watch?feature=player_detailpage&v=3WgVHE5Augc#t=818
Apr 15 2014
prev sibling next sibling parent "Francesco Cattoglio" <francesco.cattoglio gmail.com> writes:
On Sunday, 13 April 2014 at 18:42:43 UTC, Alix Pexton wrote:
 The talk I watched only touched on the motivation for a new 
 format very briefly, but the gist was that the existing 
 offerings were too computationally expensive to emulate in 
 software and hardware support is not forthcoming. My 
 understanding is that this format is designed around what can 
 be done efficiently with the instructions that are available in 
 hardware today.

 A...

This would make sense, at least partially, if hardware supporting the ieee was non-existant, but apparently hardware support for the decimal64 standard is already here! Being a numerical analyst I can say I'm extremely interested when someone comes up with new interesting ideas, but as far as I can tell we still need to go down a long road before finding something better than good old floats. And I really think that one should stick to the standards, as long as the standard is good enough. On a side note, I think that support for decimal64 might be something nice to have in the D language, because apparently that one is the most used floating point type in the economic sectors.
Apr 14 2014
prev sibling parent "Poyeyo" <poyeyo arcadechaser.com> writes:
On Tuesday, 15 April 2014 at 07:12:41 UTC, Alix Pexton wrote:
 I contacted Doug to ask if he had any additional resources that 
 I could use to make my argument for DEC64. I only got a brief 
 reply (happy to get any reply from someone so busy) to the 
 effect that everything he has to say on the matter is in the 
 motivation segment of his web site for the proposal [1].

 The most salient part is the last 2 sentences...

	A later revision of IEEE 754 attempted to remedy this, but the
	formats it recommended were so inefficient that it has not
	found much acceptance. DEC64 is a better alternative.

I encourage anyone who is dismissive of the adoption of DEC64 or who would prefer to see the IEEE decimal floats implemented to take the time to read the full article. I also recommend the presentation that alerted me to DEC64 either in full (46:10) [2] or at least just the segment about numbers [3]. A... [1] http://dec64.org [2] https://www.youtube.com/watch?v=3WgVHE5Augc [3] https://www.youtube.com/watch?feature=player_detailpage&v=3WgVHE5Augc#t=818

I believe one form of decimal64 was intended for inclusion in D since at least 2009, according to this article: http://dlang.org/d-floating-point.html
Jun 10 2014