Created
November 12, 2020 23:38
-
-
Save nerdralph/f630ba44093241d05bdaf12c11a19a6a to your computer and use it in GitHub Desktop.
generate lookup table for powers of 1.414, i.e. sqrt(2)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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