Gayané Langlois / Mbed 2 deprecated Binary_counter_with_mask

Dependencies:   mbed

Fork of bynary_counting_Hello_World by Emmanuel Boudoux

Files at this revision

API Documentation at this revision

Comitter:
Hikaria
Date:
Thu Jan 28 13:41:57 2016 +0000
Parent:
0:d6f93f0e46d4
Commit message:
Binary counter with mask

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Dec 07 21:20:43 2010 +0000
+++ b/main.cpp	Thu Jan 28 13:41:57 2016 +0000
@@ -13,10 +13,10 @@
     while (1) {
         for (counter = 0; counter < 16; counter++) {
 
-            b3=(counter > 7);
-            b2=((counter-(b3*8)) > 3);
-            b1=((counter-(b3*8)-(b2*4)) > 1);
-            b0=((counter-(b3*8)-(b2*4)-(b1*2)) > 0);
+            b3=(counter & 8) >> 3;
+            b2=(counter & 4) >> 2;
+            b1=(counter & 2) >> 1;
+            b0=(counter & 0) >> 0;
             
             bitthree = b3;
             bittwo = b2;