[erlang-bugs] error in rem operator
Daniel Luna
luna@REDACTED
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:
>
> /////
> -module(fact).
> -export([fact/1]).
>
> fact(N) -> fact(N,1).
> fact(0,P) -> P;
> fact(N,P) -> fact(N-1,P*N).
> /////
>
> Now from the shell I did this:
>
> c(fact).
> 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.
48860503.....9999999999999
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)
/Luna
--
Daniel Luna | Top reasons that I have a beard:
luna@REDACTED | 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
mailing list