Added comparison program for different floating point conversions
This commit is contained in:
parent
cef87f124d
commit
8f144cfdb3
1 changed files with 23 additions and 0 deletions
23
ColorConvertBenchmark/ColorConvertBenchmark.ino
Normal file
23
ColorConvertBenchmark/ColorConvertBenchmark.ino
Normal 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));
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue