[Issue 2973] std.math.pow(int, int), etc.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Aug 11 04:58:07 PDT 2009


http://d.puremagic.com/issues/show_bug.cgi?id=2973


Don <clugdbug at yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug at yahoo.com.au




--- Comment #6 from Don <clugdbug at yahoo.com.au>  2009-08-11 04:58:06 PDT ---
> Casting to floating point is not a good solution b/c
> you lose performance and, in some cases, precision.

Are you sure?
Performance: 
Floating point multiplication is typically the same speed or faster than
integer multiplication on most CPUs from the past 15 years. On most Intel CPUs,
integer multiplication is actually done in the floating point unit.

Precision:
You'll only lose precision if the base is greater than the 1/real.epsilon. For
an 80-bit real, this means precision is lost only when the result is exactly
equal to ulong.max. And the only time that can happen is with pow(ulong.max,
1).
(because ulong.max is divisible by 5, but not by 25).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list