Bug Of pow in std.math

Simen kjaeraas simen.kjaras at gmail.com
Thu Jul 1 01:55:59 PDT 2010


sins666 <d-bugmail at puremagic.com> wrote:

> import std.math;
> import std.stdio;
>
> void main()
> {
>     writeln(pow(5, 2)); // 25
>     writeln(pow(5, 0)); // 1
>     writeln(pow(5, -3)); // object.Error: Integer Divide by Zero
> }
>
> And dmd version is 2.047.
> Was I mistake in my source.or bug?

The mistake is in your code. std.math.pow has a version that takes
only integers, and returns only integers. That is the version you
are using.

If instead you try:

writeln(pow(5.0, -3.0));

You should see improvement.

-- 
Simen


More information about the Digitalmars-d-bugs mailing list