Integer cube root
问题 I'm looking for fast code for 64-bit (unsigned) cube roots. (I'm using C and compiling with gcc, but I imagine most of the work required will be language- and compiler-agnostic.) I will denote by ulong a 64-bit unisgned integer. Given an input n I require the (integral) return value r to be such that r * r * r <= n && n < (r + 1) * (r + 1) * (r + 1) That is, I want the cube root of n, rounded down. Basic code like return (ulong)pow(n, 1.0/3); is incorrect because of rounding toward the end of