浮动VS双重性能 [英] Float vs Double Performance

查看:222
本文介绍了浮动VS双重性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了一些时间测试,也读过一些文章像<一个href="http://www.cincomsmalltalk.com/userblogs/buck/blogView?showComments=true&title=Smalltalk%2Bperformance%2Bvs.%2BC%23&entry=3354595110#3354595110">this 之一(最后的评论),它看起来像在发布版本,float和double值将处理时间相同。

I did some timing tests and also read some articles like this one (last comment),and it looks like in Release build, float and double values take the same amount of processing time.

这怎么可能呢?当浮动不太precise和更小的相比,双精度值,如何能在CLR获得双打成相同的处理时间?

How is this possible? When float is less precise and smaller compared to double values, how can the CLR get doubles into the same processing time?


双打比在C 花车更快的精确副本

推荐答案

在x86处理器,至少,浮动将每一个可以通过将FPU进行处理转换成一个10字节的真实。该FPU不具有独立的处理单元,它支持不同的浮点类型。

On x86 processors, at least, float and double will each be converted to a 10-byte real by the FPU for processing. The FPU doesn't have separate processing units for the different floating-point types it supports.

在古老的意见,浮动更快的双进行100年前,当大多数CPU都没有有内置的FPU(和几个人有单独的FPU芯片),所以大部分的浮点操作软件完成。在这些机器上(这是由熔岩坑产生的蒸汽驱动),它的的更快地使用浮动秒。现在唯一的真正的好处浮动 s是,他们占用空间少(只有事项,如果你有百万人)。

The age-old advice that float is faster than double applied 100 years ago when most CPUs didn't have built-in FPUs (and few people had separate FPU chips), so most floating-point manipulation was done in software. On these machines (which were powered by steam generated by the lava pits), it was faster to use floats. Now the only real benefit to floats is that they take up less space (which only matters if you have millions of them).

这篇关于浮动VS双重性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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