half datatype?

Walter Bright newshound2 at digitalmars.com
Sun Nov 18 20:19:05 PST 2012


On 11/18/2012 4:31 PM, Manu wrote:
> If I told you this is how real should be implemented, would you vote ++? What
> about double? Why?
> Why not float for that matter? There seems like no reason for the language to
> define any floating point type at all if you consider this acceptable...

Because they are implemented in hardware. It's pretty dang hard for a compiler 
to look at a floating point emulator and figure out "gee, I have a nice hardware 
instruction that does the same thing as this 2K of code!"

> 'half' isn't some custom float for niche use, it's an established standard,
> implemented in vastly more hardware than implements 'real'.

It's implemented in GPUs, sure, but it is it implemented in hardware that D runs 
on? (I do know about this: 
http://gcc.gnu.org/onlinedocs/gcc/Half_002dPrecision.html)

There is no major technical difficulty in implementing it as a basic type, but I 
want to be sure we've exhausted the library approach first.


More information about the Digitalmars-d mailing list