[erlang-bugs] : error in rem operator

Raimo Niskanen raimo+erlang-bugs@REDACTED
Thu May 10 10:10:00 CEST 2007


Thank you guys!

The bug is recognized. We will invesigate it.


On Thu, May 10, 2007 at 09:44:45AM +0200, Daniel Luna wrote:
> 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.
> _______________________________________________
> erlang-bugs mailing list
> erlang-bugs@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-bugs

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB



More information about the erlang-bugs mailing list