S spectrum New Member Sep 18, 2012 #1 Hi, what is the easiest way to count "on" bits in a byte ? Thx, Spectrum
hippy Ex-Staff (retired) Sep 18, 2012 #2 Depends on the PICAXE ... There's the NOB ( number of bits ) unary function for PICAXE X2 ... Let b1 = NOB b0 or, assuming the byte is in b0 ... Let b1 = bit7+bit6+bit5+bit4+bit3+bit2+bit1+bit0
Depends on the PICAXE ... There's the NOB ( number of bits ) unary function for PICAXE X2 ... Let b1 = NOB b0 or, assuming the byte is in b0 ... Let b1 = bit7+bit6+bit5+bit4+bit3+bit2+bit1+bit0