Mercurial > hg > qm-dsp
diff maths/MathUtilities.cpp @ 135:0fdbb93e92b7
Factorial: return double (int not big enough for many popular values)
author | Chris Cannam |
---|---|
date | Wed, 16 Oct 2013 16:44:14 +0100 |
parents | 5351b5e9ad9f |
children | e4a57215ddee |
line wrap: on
line diff
--- a/maths/MathUtilities.cpp Wed Oct 16 13:29:00 2013 +0100 +++ b/maths/MathUtilities.cpp Wed Oct 16 16:44:14 2013 +0100 @@ -379,11 +379,11 @@ else return n1; } -int +double MathUtilities::factorial(int x) { if (x < 0) return 0; - int f = 1; + double f = 1; for (int i = 1; i <= x; ++i) { f = f * i; }