Last active
January 2, 2016 04:39
-
-
Save drinkcat/8252415 to your computer and use it in GitHub Desktop.
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> | |
/* | |
ARM output: | |
delay=45 | |
delay=45 | |
delay=97346 | |
delay=-45 | |
x86 output: | |
delay=45 | |
delay=45 | |
delay=97346 | |
delay=-45 | |
x86-64 output: | |
delay=45 | |
delay=45 | |
delay=-45 | |
delay=-45 | |
*/ | |
#include <stdio.h> | |
long getdelay(long latencynsec, unsigned int rate) { | |
return latencynsec / rate; | |
} | |
long getdelay2(long latencynsec, unsigned int rate) { | |
return latencynsec / (long)rate; | |
} | |
int main() { | |
long delayp; | |
unsigned int rate = 44100; | |
delayp = getdelay(2000000, rate); | |
printf("delay=%ld\n", delayp); | |
delayp = getdelay2(2000000, rate); | |
printf("delay=%ld\n", delayp); | |
delayp = getdelay(-2000000, rate); | |
printf("delay=%ld\n", delayp); | |
delayp = getdelay2(-2000000, rate); | |
printf("delay=%ld\n", delayp); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment