digitalmars.D - add phobos module std.halffloat ?
- Walter Bright (1/1) Dec 18 2012 https://github.com/D-Programming-Language/phobos/pull/1018/files
- Jacob Carlborg (5/6) Dec 18 2012 Cool, Walter does a pull request. Should this be put in the review queue...
- =?UTF-8?B?QWxleCBSw7hubmUgUGV0ZXJzZW4=?= (7/11) Dec 19 2012 Seems a bit overkill to throw it in the review queue, but I don't know
- Walter Bright (6/15) Dec 19 2012 Probably the main point of this module is to demonstrate how to do new
- Iain Buclaw (16/35) Dec 19 2012 ttps://github.com/D-Programming-Language/phobos/pull/1018/files>
- tn (2/44) Dec 19 2012 What is the difference between std.numeric.CustomFloat and this?
- Iain Buclaw (8/51) Dec 19 2012 es>
- Robert Jacques (8/19) Dec 19 2012 [snip]
- Walter Bright (4/10) Dec 19 2012 You'd have to add support for add, sub, mul, div, and compare. The halff...
- d coder (2/8) Dec 19 2012 +1
- Robert Jacques (7/16) Dec 19 2012 See std.numeric.CustomFloat. It supports quarter, half, single, double a...
- Rob T (7/13) Dec 19 2012 I did not see anything in the reference docs to indicate
- Robert Jacques (11/24) Dec 19 2012 CustomFloat is for storage purposes only. All operations are prefixed by...
- ponce (9/10) Dec 19 2012 If that ever helps, I implemented this fast conversion
- Walter Bright (2/12) Dec 19 2012 The pdf file shows as corrupted.
- Robert Jacques (3/18) Dec 19 2012 It opens fine for me. (Win7/Adobe Reader 10.0.1)
- =?UTF-8?B?TWFydGluIERyYcWhYXI=?= (7/22) Dec 19 2012 Happened to me as well when I clicked on the link. It worked fine after
- Walter Bright (2/4) Dec 19 2012 Thanks, that worked.
- Walter Bright (5/15) Dec 19 2012 Thanks, I read the paper. It looks interesting. I did notice, however, t...
- Andrei Alexandrescu (7/8) Dec 19 2012 Shouldn't it be part of std.numeric?
- Robert Jacques (29/37) Dec 19 2012 It _IS_ part of std.numeric! Specifically std.numeric.CustomFloat!16; To...
- tn (10/25) Dec 21 2012 Why is it in std.numeric anyway? I would expect std.numeric to
On 2012-12-19 08:30, Walter Bright wrote:https://github.com/D-Programming-Language/phobos/pull/1018/filesCool, Walter does a pull request. Should this be put in the review queue or is this a small enough change to be added anyway? -- /Jacob Carlborg
Dec 18 2012
On 19-12-2012 08:35, Jacob Carlborg wrote:On 2012-12-19 08:30, Walter Bright wrote:Seems a bit overkill to throw it in the review queue, but I don't know how rigorous we want to be about that. -- Alex Rønne Petersen alex alexrp.com / alex lycus.org http://lycus.orghttps://github.com/D-Programming-Language/phobos/pull/1018/filesCool, Walter does a pull request. Should this be put in the review queue or is this a small enough change to be added anyway?
Dec 19 2012
On 12/19/2012 12:47 AM, Alex Rønne Petersen wrote:On 19-12-2012 08:35, Jacob Carlborg wrote:Probably the main point of this module is to demonstrate how to do new arithmetic types like this without needing compiler support. It also shows how to do IEEE floating point rounding correctly, which is not obvious and not trivial. This particular type is a standard type and crops up in graphics code, so there is a use for it.On 2012-12-19 08:30, Walter Bright wrote:Seems a bit overkill to throw it in the review queue, but I don't know how rigorous we want to be about that.https://github.com/D-Programming-Language/phobos/pull/1018/filesCool, Walter does a pull request. Should this be put in the review queue or is this a small enough change to be added anyway?
Dec 19 2012
On 19 December 2012 08:55, Walter Bright <newshound2 digitalmars.com> wrote= :On 12/19/2012 12:47 AM, Alex R=F8nne Petersen wrote:ttps://github.com/D-Programming-Language/phobos/pull/1018/files>On 19-12-2012 08:35, Jacob Carlborg wrote:On 2012-12-19 08:30, Walter Bright wrote:https://github.com/D-**Programming-Language/phobos/**pull/1018/files<h=eCool, Walter does a pull request. Should this be put in the review queu=owor is this a small enough change to be added anyway?Seems a bit overkill to throw it in the review queue, but I don't know h=srigorous we want to be about that.Probably the main point of this module is to demonstrate how to do new arithmetic types like this without needing compiler support. It also show=how to do IEEE floating point rounding correctly, which is not obvious an=dnot trivial.How difficult would you think it would be to scale down (or up) this library type so it can be an emulated IEEE type of any size? (The whole shebang eg: quarter, half, single, double, quad, double-quad, 80bit and 96-bit). Just interested as I think that a module which implements an IEEE floating point type that produces constant results cross-platform would be better than a dedicated module just for half float types. --=20 Iain Buclaw *(p < e ? p++ : p) =3D (c & 0x0f) + '0';
Dec 19 2012
On Wednesday, 19 December 2012 at 10:13:56 UTC, Iain Buclaw wrote:On 19 December 2012 08:55, Walter Bright <newshound2 digitalmars.com> wrote:What is the difference between std.numeric.CustomFloat and this?On 12/19/2012 12:47 AM, Alex Rønne Petersen wrote:How difficult would you think it would be to scale down (or up) this library type so it can be an emulated IEEE type of any size? (The whole shebang eg: quarter, half, single, double, quad, double-quad, 80bit and 96-bit). Just interested as I think that a module which implements an IEEE floating point type that produces constant results cross-platform would be better than a dedicated module just for half float types.On 19-12-2012 08:35, Jacob Carlborg wrote:Probably the main point of this module is to demonstrate how to do new arithmetic types like this without needing compiler support. It also shows how to do IEEE floating point rounding correctly, which is not obvious and not trivial.On 2012-12-19 08:30, Walter Bright wrote:Seems a bit overkill to throw it in the review queue, but I don't know how rigorous we want to be about that.https://github.com/D-**Programming-Language/phobos/**pull/1018/files<https://github.com/D-Programming-Language/phobos/pull/1018/files>Cool, Walter does a pull request. Should this be put in the review queue or is this a small enough change to be added anyway?
Dec 19 2012
On 19 December 2012 11:30, tn <no email.com> wrote:On Wednesday, 19 December 2012 at 10:13:56 UTC, Iain Buclaw wrote:*pull/1018/files>On 19 December 2012 08:55, Walter Bright <newshound2 digitalmars.com> wrote: On 12/19/2012 12:47 AM, Alex R=F8nne Petersen wrote:On 19-12-2012 08:35, Jacob Carlborg wrote:On 2012-12-19 08:30, Walter Bright wrote:https://github.com/D-****Programming-Language/phobos/****pull/1018/files<https://github.com/D-**Programming-Language/phobos/*=es><https://**github.com/D-Programming-**Language/phobos/pull/1018/** files<https://github.com/D-Programming-Language/phobos/pull/1018/fil=With this, there's a choice of rounding modes, casting between float and integral types, and the fact that not many people know about it? --=20 Iain Buclaw *(p < e ? p++ : p) =3D (c & 0x0f) + '0';What is the difference between std.numeric.CustomFloat and this?library type so it can be an emulated IEEE type of any size? (The whole shebang eg: quarter, half, single, double, quad, double-quad, 80bit and 96-bit). Just interested as I think that a module which implements an IEEE floating point type that produces constant results cross-platform would be better than a dedicated module just for half float types.Probably the main point of this module is to demonstrate how to do new arithmetic types like this without needing compiler support. It also shows how to do IEEE floating point rounding correctly, which is not obvious and not trivial. How difficult would you think it would be to scale down (or up) thisknow how rigorous we want to be about that.Cool, Walter does a pull request. Should this be put in the review queue or is this a small enough change to be added anyway? Seems a bit overkill to throw it in the review queue, but I don't
Dec 19 2012
On Wed, 19 Dec 2012 05:47:38 -0600, Iain Buclaw <ibuclaw ubuntu.com> wro= te:On 19 December 2012 11:30, tn <no email.com> wrote:[snip]On Wednesday, 19 December 2012 at 10:13:56 UTC, Iain Buclaw wrote:On 19 December 2012 08:55, Walter Bright <newshound2 digitalmars.com=wrote: On 12/19/2012 12:47 AM, Alex R=F8nne Petersen wrote:On 19-12-2012 08:35, Jacob Carlborg wrote:On 2012-12-19 08:30, Walter Bright wrote:andWhat is the difference between std.numeric.CustomFloat and this?With this, there's a choice of rounding modes, casting between float =integral types, and the fact that not many people know about it?*Ahem* That should be possible future support for rounding modes. = Currently, the code paths exist but are restricted to ROUND.TONEAREST. I= 'm = not sure why this is given std.math.FloatingPointControl.rounding.
Dec 19 2012
On 12/19/2012 2:13 AM, Iain Buclaw wrote:How difficult would you think it would be to scale down (or up) this library type so it can be an emulated IEEE type of any size? (The whole shebang eg: quarter, half, single, double, quad, double-quad, 80bit and 96-bit). Just interested as I think that a module which implements an IEEE floating point type that produces constant results cross-platform would be better than a dedicated module just for half float types.You'd have to add support for add, sub, mul, div, and compare. The halffloat only does conversions. Other than that, the algorithm used is quite extendible to other IEEE types.
Dec 19 2012
On Wed, Dec 19, 2012 at 3:43 PM, Iain Buclaw <ibuclaw ubuntu.com> wrote:How difficult would you think it would be to scale down (or up) this library type so it can be an emulated IEEE type of any size? (The whole shebang eg: quarter, half, single, double, quad, double-quad, 80bit and 96-bit). Just interested as I think that a module which implements an IEEE floating point type that produces constant results cross-platform would be better than a dedicated module just for half float types.+1
Dec 19 2012
On Wed, 19 Dec 2012 04:49:59 -0600, d coder <dlang.coder gmail.com> wrote:On Wed, Dec 19, 2012 at 3:43 PM, Iain Buclaw <ibuclaw ubuntu.com> wrote:See std.numeric.CustomFloat. It supports quarter, half, single, double and 80-bit. The wikipedia article on the floating point (IEEE 754) includes a Quad type but not a double-quad or 96-bit type. 96-bit Should be possible, as it's just 80-bits with padding. Quad and double quad would be tougher to do, do to the lack of a quad integer type or a 112-bit bit shift operator.How difficult would you think it would be to scale down (or up) this library type so it can be an emulated IEEE type of any size? (The whole shebang eg: quarter, half, single, double, quad, double-quad, 80bit and 96-bit). Just interested as I think that a module which implements an IEEE floating point type that produces constant results cross-platform would be better than a dedicated module just for half float types.+1
Dec 19 2012
On Wednesday, 19 December 2012 at 20:44:19 UTC, Robert Jacques wrote:See std.numeric.CustomFloat. It supports quarter, half, single, double and 80-bit. The wikipedia article on the floating point (IEEE 754) includes a Quad type but not a double-quad or 96-bit type. 96-bit Should be possible, as it's just 80-bits with padding. Quad and double quad would be tougher to do, do to the lack of a quad integer type or a 112-bit bit shift operator.I did not see anything in the reference docs to indicate consistency across platform. Do these produce constant results cross-platform? Actually do any of the basic floating point types do this (Real excluded)? --rt
Dec 19 2012
On Thu, 20 Dec 2012 00:06:04 -0600, Rob T <rob ucora.com> wrote:On Wednesday, 19 December 2012 at 20:44:19 UTC, Robert Jacques wrote:CustomFloat is for storage purposes only. All operations are prefixed by converting the custom float to real first, which is what x86 does internally. This is in the Ddoc comments in the code, but because CustomFloat is a template, they don't appear in the html docs. As for consistent results, you do get a consistent storage size, which you don't get with real, but aside from that, IEEE only specifies a minimum accuracy for each operation. Combined with truncation issues, this means that results will very from platform to platform and from compiler to compiler. There is nothing new about this. In fact, x86 is more precise than x86-64 due to the switch from the x87 to SSE for floats/doubles.See std.numeric.CustomFloat. It supports quarter, half, single, double and 80-bit. The wikipedia article on the floating point (IEEE 754) includes a Quad type but not a double-quad or 96-bit type. 96-bit Should be possible, as it's just 80-bits with padding. Quad and double quad would be tougher to do, do to the lack of a quad integer type or a 112-bit bit shift operator.I did not see anything in the reference docs to indicate consistency across platform. Do these produce constant results cross-platform? Actually do any of the basic floating point types do this (Real excluded)? --rt
Dec 19 2012
On Wednesday, 19 December 2012 at 07:30:54 UTC, Walter Bright wrote:https://github.com/D-Programming-Language/phobos/pull/1018/filesIf that ever helps, I implemented this fast conversion ftp://www.fox-toolkit.org/pub/fasthalffloatconversion.pdf for a half wrapper here: https://github.com/p0nce/gfm/blob/master/math/half.d It's woefully untested though. In 3D graphics efficiently converting float to half can speed up vertex submission.
Dec 19 2012
On 12/19/2012 2:22 AM, ponce wrote:On Wednesday, 19 December 2012 at 07:30:54 UTC, Walter Bright wrote:The pdf file shows as corrupted.https://github.com/D-Programming-Language/phobos/pull/1018/filesIf that ever helps, I implemented this fast conversion ftp://www.fox-toolkit.org/pub/fasthalffloatconversion.pdf for a half wrapper here: https://github.com/p0nce/gfm/blob/master/math/half.d It's woefully untested though. In 3D graphics efficiently converting float to half can speed up vertex submission.
Dec 19 2012
On Wed, 19 Dec 2012 13:48:29 -0600, Walter Bright <newshound2 digitalmars.com> wrote:On 12/19/2012 2:22 AM, ponce wrote:It opens fine for me. (Win7/Adobe Reader 10.0.1)On Wednesday, 19 December 2012 at 07:30:54 UTC, Walter Bright wrote:The pdf file shows as corrupted.https://github.com/D-Programming-Language/phobos/pull/1018/filesIf that ever helps, I implemented this fast conversion ftp://www.fox-toolkit.org/pub/fasthalffloatconversion.pdf for a half wrapper here: https://github.com/p0nce/gfm/blob/master/math/half.d It's woefully untested though. In 3D graphics efficiently converting float to half can speed up vertex submission.
Dec 19 2012
Dne 19.12.2012 20:48, Walter Bright napsal(a):On 12/19/2012 2:22 AM, ponce wrote:Happened to me as well when I clicked on the link. It worked fine after copy+pasting the link into the browser. Also it did not work when I tried it in two different browsers. I have temporary uploaded correctly working pdf version here: http://mysharegadget.com/528634723 MartinOn Wednesday, 19 December 2012 at 07:30:54 UTC, Walter Bright wrote:The pdf file shows as corrupted.https://github.com/D-Programming-Language/phobos/pull/1018/filesIf that ever helps, I implemented this fast conversion ftp://www.fox-toolkit.org/pub/fasthalffloatconversion.pdf for a half wrapper here: https://github.com/p0nce/gfm/blob/master/math/half.d It's woefully untested though. In 3D graphics efficiently converting float to half can speed up vertex submission.
Dec 19 2012
On 12/19/2012 12:28 PM, Martin Drašar wrote:Also it did not work when I tried it in two different browsers. I have temporary uploaded correctly working pdf version here: http://mysharegadget.com/528634723Thanks, that worked.
Dec 19 2012
On 12/19/2012 2:22 AM, ponce wrote:On Wednesday, 19 December 2012 at 07:30:54 UTC, Walter Bright wrote:Thanks, I read the paper. It looks interesting. I did notice, however, that it does not appear to do IEEE rounding correctly (unless I misunderstood the code), nor does it have any hooks for detection of Inexact, Underflow and Overflow. These come into play when converting a float to a half.https://github.com/D-Programming-Language/phobos/pull/1018/filesIf that ever helps, I implemented this fast conversion ftp://www.fox-toolkit.org/pub/fasthalffloatconversion.pdf for a half wrapper here: https://github.com/p0nce/gfm/blob/master/math/half.d It's woefully untested though. In 3D graphics efficiently converting float to half can speed up vertex submission.
Dec 19 2012
On 12/19/12 2:30 AM, Walter Bright wrote:https://github.com/D-Programming-Language/phobos/pull/1018/filesShouldn't it be part of std.numeric? Related, we should have a decision point "this must go through the review process" vs. "the pull review process is sufficient". New modules definitely must go through the review process, as should large additions to existing models. Andrei
Dec 19 2012
On Wed, 19 Dec 2012 09:35:39 -0600, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:On 12/19/12 2:30 AM, Walter Bright wrote:It _IS_ part of std.numeric! Specifically std.numeric.CustomFloat!16; To quote our own documentation: // Define a 16-bit floating point values CustomFloat!16 x; // Using the number of bits CustomFloat!(10, 5) y; // Using the precision and exponent width CustomFloat!(10, 5,CustomFloatFlags.ieee) z; // Using the precision, exponent width and format flags CustomFloat!(10, 5,CustomFloatFlags.ieee, 15) w; // Using the precision, exponent width, format flags and exponent offset bias // Use the 16-bit floats mostly like normal numbers w = x*y - 1; writeln(w); // Functions calls require conversion z = sin(+x) + cos(+y); // Use uniary plus to concisely convert to a real z = sin(x.re) + cos(y.re); // Or use the .re property to convert to a real z = sin(x.get!float) + cos(y.get!float); // Or use get!T z = sin(cast(float)x) + cos(cast(float)y); // Or use cast(T) to explicitly convert ------------------- The only item missing from std.numeric.CustomFloat is to add an alias this line so that implicit conversion is supported. Oh, and documentation of the standard float properties, such as infinity/min/min/etc, which exist in the code, but are template methods and so don't appear in the ddoc.https://github.com/D-Programming-Language/phobos/pull/1018/filesShouldn't it be part of std.numeric? Related, we should have a decision point "this must go through the review process" vs. "the pull review process is sufficient". New modules definitely must go through the review process, as should large additions to existing models. Andrei
Dec 19 2012
On Wednesday, 19 December 2012 at 19:52:41 UTC, Robert Jacques wrote:On Wed, 19 Dec 2012 09:35:39 -0600, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:Why is it in std.numeric anyway? I would expect std.numeric to contain numerical algorithms, not something like this. Suggestion: Combine HalfFloat with CustomFloat and move the result in a separate module, say std.float. Also move there IeeeFlags, FloatingPointControl, NaN, getNaNPayload, nextUp, nextDown, nextafter and related things. Those have nothing to do with math. Possibly also isNaN, isFinite, isNormal, isSubnormal and isInfinity.On 12/19/12 2:30 AM, Walter Bright wrote:It _IS_ part of std.numeric!https://github.com/D-Programming-Language/phobos/pull/1018/filesShouldn't it be part of std.numeric? Related, we should have a decision point "this must go through the review process" vs. "the pull review process is sufficient". New modules definitely must go through the review process, as should large additions to existing models. Andrei
Dec 21 2012