Why does D not have generics?

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Sat Jan 16 19:43:53 UTC 2021


On Saturday, 16 January 2021 at 17:03:41 UTC, Bruce Carneal wrote:
> Converting over:
> 	uint32 mask = -int32(f >> 31) | 0x80000000;
> 	return f ^ mask;
> and back:
> 	uint32 mask = ((f >> 31) - 1) | 0x80000000;
> 	return f ^ mask;

Thanks, this is the same I have as option 1 above.

> This form is branchless and is easily (SIMD) vectorized.

Yes, and perhaps also better for the CPU pipeline.

> split, ordering.  For my current work I prefer this to 
> traditional float behavior and find it a useful bijection 
> overall.  YMMV.

Out of curiosity, what do you need to sort floats for?



More information about the Digitalmars-d mailing list