comparison maths/MathUtilities.h @ 360:a694700f71d8

Factorial: return double (int not big enough for many popular values)
author Chris Cannam <c.cannam@qmul.ac.uk>
date Wed, 16 Oct 2013 16:44:14 +0100
parents a067c2eeb13c
children 59b151f13b3e
comparison
equal deleted inserted replaced
359:0ea56b09577e 360:a694700f71d8
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