half datatype?

Walter Bright newshound2 at digitalmars.com
Mon Nov 19 12:52:16 PST 2012


On 11/19/2012 8:04 AM, Manu wrote:
> Well it's available in hardware on basically all mobile devices (that's a LOT of
> devices (in the billions)), but even if it's just implemented in software (x86),
> the values are consumed by the GPU, and the validity of the values is no less
> important. It still seems like a valuable 1st class type; why shouldn't it enjoy
> the same casting, assignment, literal, range checking rules as the rest of the
> floats? Additionally, convenience and compatibility with generic code would be
> significantly improved.
> I don't see how it can be made to feel seamless with a lib... and that sounds
> like an awful lot more work.

By making a library type that implicitly converts to/from float, and then doing 
the operations on float, that should about cover it.

For the ARM, the conversion itself could be done by a builtin function, which 
can use the ARM hardware instruction for it.

For literals, I think:

     __fp16(3.5)

coupled with UTFE can work.


> Anyway, I'm not desperate for this personally. I just wondered how people felt
> about it in general, and if it was something that should/would be seriously
> considered.

I think it should be considered.


More information about the Digitalmars-d mailing list