Created
October 25, 2013 12:30
-
-
Save Makistos/7153938 to your computer and use it in GitHub Desktop.
This simple code snippet shows how interpolating can be done in C using signed integers. The for() loop determinest the range to interpolate from. In this case -100 to +100. For loop is here just to work as an example. 12th line is were the work is done. 256.0 is the top end of the range while 201.0 is the number of values in the list to be inte…
This file contains hidden or 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
#include <stdio.h> | |
#include <math.h> | |
int main() | |
{ | |
int result; | |
double x; | |
int i; | |
for (i=-100;i<101;i++) | |
{ | |
x = (256.0/201.0*i +127); | |
if (x>=0) result = (x+0.5f); | |
else result = (x-0.5f); | |
printf("%d => %d\n", i, result); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment