pow how

I was going to post a bug suggestion, but then I realized that the "pow()" function returns a double precision number.

I was going insane over this not returning expected integer (or byte) values:

greenByte = (byte)pow(2,rowCounter) ;  // green testpattern

It worked until it should return values above 2... it should be 1,2,4,8,16...etc but instead it returned 1,2,3,7,15,31....

This fixed that, and also made the compiled code almost 2k shorter:

    greenByte = 1;
    for(int i=0;i<rowCounter;i++) greenByte *= 2;

I just wanted to mention that, in case others have similar problems. I guess it is not a bug, just some inaccuracies due to it being a double precision (kind of a counterintuitive name in this respect though :stuck_out_tongue: )

Oh, and the hightlight in the IDE for the pow() function still isnt fixed, but I guess thats a minor, minor flaw.

I believe you can shorten it even further with this...

greenByte = 1 << rowCounter;

Coding Badly: Great, thanks! You don't live up to your name :slight_smile: