www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15249] New: Floating-point division should multiply by


          Issue ID: 15249
           Summary: Floating-point division should multiply by inverse if
           Product: D
           Version: D2
          Hardware: x86_64
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: Marco.Leise gmx.de

For ages we have been writing "x * 0.5f" because it would be faster than
division by 2. I've just checked back with what GDC and LDC2 and they generate
the same code for "* 0.5" and "/ 2", recognizing that the inverse is lossless,
while DMD still uses division for the latter.

This applies to all divisions by powers of two up to a practical limit like the
range limit of a ulong 1/2⁶⁴ or the smallest normalized single-precision
1/2¹²⁶ in case 128-bit cent/ucent are fully implemented.

Oct 26 2015