Added comparison program for different floating point conversions

This commit is contained in:
Nis Wechselberg 2017-03-13 08:28:59 +01:00
parent cef87f124d
commit 8f144cfdb3

View file

@ -0,0 +1,23 @@
void setup() {
}
void loop() {
convert1(129);
convert2(129);
convert3(129);
}
int convert1(int color_in) {
return 4096 / ( 256 / color_in);
}
int convert2(int color_in) {
return color_in << 4;
}
int convert3(int color_in) {
return (int) (4096 / ( 256 / (float) color_in));
}