December 20, 2012 Re: add phobos module std.halffloat ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Rob T | 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:
>>
>> 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
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.
|
December 21, 2012 Re: add phobos module std.halffloat ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert Jacques | 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:
>
>> On 12/19/12 2:30 AM, Walter Bright wrote:
>>> https://github.com/D-Programming-Language/phobos/pull/1018/files
>>
>> Shouldn'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
>
> It _IS_ part of std.numeric!
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.
|
Copyright © 1999-2021 by the D Language Foundation