Skip to content

Instantly share code, notes, and snippets.

@nerdralph
Created Nov 12, 2020
Embed
What would you like to do?
generate lookup table for powers of 1.414, i.e. sqrt(2)
// Ralph Doncaster 2020 public domain software
// generate lookup table for powers of sqrt(2)
#include <stdio.h>
#include <math.h>
int main()
{
double sqrt2 = sqrt(2.0);
for (double d = 2; d <= 16; d += 1) {
printf( "1.414^%d = %lf\n", (int)d, pow(sqrt2, d) );
}
printf("powers[] = { 0");
for (double d = 2; d <= 16; d += 1) {
printf( ", %d", (int) (pow(sqrt2, d) + 0.5) );
}
printf(" };\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment