[erlang-bugs] error in rem operator
Thu May 10 09:44:45 CEST 2007
On Thu, 10 May 2007, Jay Anderson wrote:
> I think I may have found a bug. Here's my factorial function:
> fact(N) -> fact(N,1).
> fact(0,P) -> P;
> fact(N,P) -> fact(N-1,P*N).
> Now from the shell I did this:
> X = fact:fact(1000).
> X rem 823543. %7^7=823543
> This incorrectly gives 823543 instead of 0. Thanks!
There is something very strange going on here.
Look at the result of:
X div 823543.
823543 is a factor of X, so X is evenly divisible by 823543. That means
that the rest of the prime factors in X should still be there. I am
missing a whole lot of 0s.
(Tested on R11B-2)
Daniel Luna | Top reasons that I have a beard:
| a) Laziness.
http://www.update.uu.se/~luna/ | b) I can.
Don't look at my homepage (it stinks).| c) I can get away with it.
More information about the erlang-bugs