Skip to content

Instantly share code, notes, and snippets.

@evilscientress
Last active June 30, 2017 17:02
Show Gist options
  • Save evilscientress/d107924eb0a7b705cb0cc4f694c34bf6 to your computer and use it in GitHub Desktop.
Save evilscientress/d107924eb0a7b705cb0cc4f694c34bf6 to your computer and use it in GitHub Desktop.
divides stuff by 12 to test other stuff
#include <stdio.h>
void main(void){
for(int i=-13;i<=13;i++){
int iresult=i/12;
float fresult=((float)i)/12.0f;
printf("%d\t%d\t%d\t%f\n",i,iresult,((int)fresult),fresult);
}
}
/*
-13 -1 -1 -1.083333
-12 -1 -1 -1.000000
-11 0 0 -0.916667
-10 0 0 -0.833333
-9 0 0 -0.750000
-8 0 0 -0.666667
-7 0 0 -0.583333
-6 0 0 -0.500000
-5 0 0 -0.416667
-4 0 0 -0.333333
-3 0 0 -0.250000
-2 0 0 -0.166667
-1 0 0 -0.083333
0 0 0 0.000000
1 0 0 0.083333
2 0 0 0.166667
3 0 0 0.250000
4 0 0 0.333333
5 0 0 0.416667
6 0 0 0.500000
7 0 0 0.583333
8 0 0 0.666667
9 0 0 0.750000
10 0 0 0.833333
11 0 0 0.916667
12 1 1 1.000000
13 1 1 1.083333
*/
for i in range(-13,14):
iresult = i//12
fresult = i/12
print('%d\t%d\t%d\t%f' % (i, iresult, int(fresult), fresult))
'''
-13 -2 -1 -1.083333
-12 -1 -1 -1.000000
-11 -1 0 -0.916667
-10 -1 0 -0.833333
-9 -1 0 -0.750000
-8 -1 0 -0.666667
-7 -1 0 -0.583333
-6 -1 0 -0.500000
-5 -1 0 -0.416667
-4 -1 0 -0.333333
-3 -1 0 -0.250000
-2 -1 0 -0.166667
-1 -1 0 -0.083333
0 0 0 0.000000
1 0 0 0.083333
2 0 0 0.166667
3 0 0 0.250000
4 0 0 0.333333
5 0 0 0.416667
6 0 0 0.500000
7 0 0 0.583333
8 0 0 0.666667
9 0 0 0.750000
10 0 0 0.833333
11 0 0 0.916667
12 1 1 1.000000
13 1 1 1.083333
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment