[Issue 7006] std.math.pow (integral, integral) crashes on negative exponents
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Dec 2 05:02:07 PST 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7006
--- Comment #3 from Don <clugdbug at yahoo.com.au> 2011-12-02 05:01:01 PST ---
(In reply to comment #2)
> That is like saying 1/2 should give a div by zero error because the result does
> not fit in an integer and therefore it must always indicate a bug.
Accidental use of integer division instead of floating point division is a
very, very common bug.
> I want this:
>
> assert(a ^^ -1 == 1/a);
Why do you want that? Do you have any use cases where it's not a bug?
> This is only div by zero if a is zero.
>
>
> (BTW: This does not give a div by zero error on my x86 machine, and I have no
> clue why you think it should: void main(){auto x = -1; x = x/(x-int.max);})
Sorry, got it upside down. It's -int.max -1, divided by -1.
This generates a hardware division error. Depending on the OS, your OS may
inspect the operands to determine if it is a div by zero, or this special case:
void main(){auto x = 1; x = (-1-int.max)/-x;}
--
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