comparison maths/MathUtilities.h @ 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 0d3b3c66652b
comparison
equal deleted inserted replaced
134:5f88f517b637 135:0fdbb93e92b7
63 static bool isPowerOfTwo(int x); 63 static bool isPowerOfTwo(int x);
64 static int nextPowerOfTwo(int x); // e.g. 1300 -> 2048, 2048 -> 2048 64 static int nextPowerOfTwo(int x); // e.g. 1300 -> 2048, 2048 -> 2048
65 static int previousPowerOfTwo(int x); // e.g. 1300 -> 1024, 2048 -> 2048 65 static int previousPowerOfTwo(int x); // e.g. 1300 -> 1024, 2048 -> 2048
66 static int nearestPowerOfTwo(int x); // e.g. 1300 -> 1024, 12 -> 16 (not 8) 66 static int nearestPowerOfTwo(int x); // e.g. 1300 -> 1024, 12 -> 16 (not 8)
67 67
68 static int factorial(int x); 68 static double factorial(int x); // returns double in case it is large
69 69
70 static int gcd(int a, int b); 70 static int gcd(int a, int b);
71 }; 71 };
72 72
73 #endif 73 #endif