yea, >>2 is the same as dividing by 4, >>3 is the same as dividing by 8 etc... you can also multiply by shifting left (e.g. <<1 is the same as multiplying by 2)
the line "time[chl] = (chnl1[chl] - 510) / -255" can of course be re-written as "time[chl] = (510 - chnl1[chl]) / 255". If you dont mind dividing by 256 instead it could also be written as "time[chl] = (510 - chnl1[chl])>>8" and would be much quicker to execute. However you must keep in mind that the result of this line is ALLWAYS going to be an integer even if the real matematical answer is 1.3 for example, the value stored in time[chl] will be 1
the same thing applies to the lines with 1.5 in them. the variables cant not possibly be equal to 1.5. You seem to be trying to check if the variable time[lmt] is bigger than, less than or equal to 1.5. This is not possible since time[lmt] is of course an integer and can only have whole values. You may need to re-think how your program works if you are trying to use a range of numbers between 1 and 2.
Perhaps you can post the equations/algorithms that you are trying to calculate and I may be able to work out what you are trying to do in your program.
Just for your reference, a variable that has been declared as a byte has 256 possible values in the set [0,1,2,...,255]. A variable that has been declared as a word has 65536 possible vlaues in the set [0,1,2,...,65535]




Bookmarks