What is the difference between a = a * (2^3) and a = a << 3?
来源:互联网 发布:免费动画制作软件 编辑:程序博客网 时间:2024/06/10 08:32
What is the difference between a = a * (2^3) and a = a <<3?
在面试题中,经常会问,如何高效的实现某个数值乘以2的n次方,标准答案一般是向左移位n位。
其实,这个跟编译器有关系的。当编译器看到常数2的n次方后,可能会直接优化成左移位操作。大家可以自己调试跟踪一下汇编代码。
- What is the difference between a = a * (2^3) and a = a << 3?
- What is the difference between a thread and a process?
- What is the difference between a definition and a declaration?
- What is the difference between a process and a thread?
- What is the difference between a processor, a chip, a socket, and a core?
- What is the difference between an EXE and a DLL?
- What is the difference between a Generative and Discriminative Algorithm?
- What is the difference between GenericServlet, HttpServlet and a Servlet?
- What is the difference between a theorem, a lemma, and a corollary?
- What Is the Difference Between a Block, a Proc, and a Lambda in Ruby
- What is the difference between a URI, a URL and a URN
- What's the difference between a thread and a process?
- What’s the difference between a stack and a heap?
- What's the difference between a URI and a URL?
- What is the difference between a von Neumann architecture and a Harvard architecture?
- What is the difference between a pack slip and a pick slip?
- What is the difference between a Bayesian network and a Naive Bayes classifier?
- In SQL, what is the difference between a left join and a left outer join?
- 培训的第一个月
- if语句中代码行过多时可能出现的bug
- 48条常用正则式
- 美国债务担忧影响,USD/CHF至历史新低
- 表连接方式概念以及在执行计划中执行步骤[摘]
- What is the difference between a = a * (2^3) and a = a << 3?
- JAVA [Time]
- C++高质量编程
- Xml Parser by leverging Xpath
- Java Concurrent包学习之BlockingQueue
- Python的专用方法
- 事件驱动
- 游戏中检测摄像机与人之间有无带碰撞器的遮挡物
- Android软件开发之ListView 详解 (十一)