add phobos module std.halffloat ?
Robert Jacques
rjacque2 at live.johnshopkins.edu
Wed Dec 19 23:46:52 PST 2012
On Thu, 20 Dec 2012 00:06:04 -0600, Rob T <rob at 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.
More information about the Digitalmars-d
mailing list