I was testing evaluating cast expressions for a debugger I'm working on, when I came across this bit of behavior that hopefully Walter or someone else can explain.
Most conversions in D from floating point to integer are done with the help of the x87 FP instructions: load FP number, store as integer. This is understandable. The following conversions are done differently: - float, double, real -> uint - float, double -> ulong They are done with the help of runtime functions called DBLULNG and DBLULLNG respectively. They work completely with x86 non-FP instructions. What I don't like about them is that they produce results that are inconsistent with the way the other conversions are handled. For example, (cast(uint) -1.0) becomes 0, whereas (cast(ulong) -1.0L) becomes 0xFFFFFFFFFFFFFFFF and (cast(ushort) -1.0L) becomes 0xFFFF.
