I\'ve been using this factorial program for Java:
public static long factorial(int a) {
if(a<1) {
return 1;
}
long result=1;
long
Check out http://en.wikipedia.org/wiki/Integer_overflow, I know the title refers to an integer but the principle stands for int, long , double etc.
In short, a primitive datatype has a max value, when you go over that, it wraps aroun and starts again. if you really want to get geeky about it, learn about binary addition to fully understand it.