Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.
Date: 2015aug14 Language: C/C++ Q. Can I use bitwise operators to speed up multiply and divides by 2? A. Dividing by 2 can be replaced by a right shifti / 2 -> i>>1 i / 4 -> i>>2Multiplying by 2 can be replaced by a left shifti * 2 -> i<<1 i * 4 -> i<<2Checking for odd or eveni % 2 -> i & 0x01
Add a commentSign in to add a comment