是乘法比浮动除法快? [英] Is multiplication faster than float division?

查看:170
本文介绍了是乘法比浮动除法快?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C / C ++,您可以设置以下code:

In C/C++, you can set up the following code:

double a, b, c;
...
c = (a + b) / 2;

这不完全一样的东西:

c = (a + b) * 0.5;

我不知道这是更好地使用。是一个操作比其他更快的根本?

I'm wondering which is better to use. Is one operation fundamentally faster than the other?

推荐答案

浮点乘法通常需要比浮点分裂周期更少。但随着文字操作数的优化很清楚这种微型优化的。

Floating point multiplication usually takes fewer cycles than floating point division. But with literal operands the optimizer is well aware of this kind of micro-optimizations.

这篇关于是乘法比浮动除法快?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆