为何浮动 [英] why float

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

问题描述

为什么C#中有一个类型的浮点数?


当然,使用整数是最好的。就像在口袋里拎着鹅卵石一样。但是如果你需要十进制浮点值,在图形

转换或科学程序中,你需要最高精度,

加倍。


我能理解像C和C ++这样的语言有两种不同的浮点数b / b点类型,float和double,因为一旦内存大小出现问题。但是现在它不是和b $ b一样,并且内置的协处理器对它们进行计算

足够快。


如果你可以从头开始定义一种语言,你为什么要''浮动''

(单精度)一种基本类型?

Why is there a type float in C#?

Working with integers is best, of course. It is like carrying pebbles around
in your pocket. But if you need decimal floating point values, in graphics
transforms or in scientific programs, you take the highest precision,
double.

I can understand that languages like C and C++ have two different floating
point types, float and double, because once memory size was an issue. But
these days it is not and build-in co-processors do computations on them
quick enough.

If you can define a language from scratch, why would you make ''float''
(single precision) a fundamental type?

推荐答案

" Martijn Mulder" < I @ M>写道:
"Martijn Mulder" <i@m> wrote:
如果你可以从头开始定义一种语言,你为什么要把''浮动''(单精度)作为基本类型?
If you can define a language from scratch, why would you make ''float''
(single precision) a fundamental type?




大多数GDI +使用花车,似乎;不是双打。和3d图形

同样如此。我的猜测是,因为浮动是32位。这使得

非常引人注目的图形。


-

Lucian



Most of GDI+ uses floats, it seems; not doubles. And 3d graphics
likewise. My guess is that it''s because float is 32bit. That makes it
tremendously compelling for graphics.

--
Lucian

Waaaay回到我的大学时代,在我的数值分析课程中,我

记住一个例子,其中到处使用双打(明显的

解决方案)实际上增加了错误并给出了一个不太精确的答案,而不是在适当的地方明智地应用花车。


不要让我记住这个确切的例子。那是很久以前的事了。


所以,是的,即使内存不是问题,浮点数也有其用途......

主要用于工程应用,我想。

Waaaay back in my university days, in my Numerical Analysis course, I
remember one example in which using doubles everywhere (the obvious
solution) actually increased error and gave a less precise answer than
judicious application of floats in the right places.

Don''t ask me to remember the precise example. That was a long time ago.

So, yes, even when memory is not an issue floats have their uses...
mostly for engineering applications, I would imagine.


性能怎么样?对于花车来说,没有太多的游戏操作比用双打游戏快得多吗?


布鲁斯伍德 <峰; br ******* @ canada.com>在消息中写道

news:11 ********************** @ g10g2000cwb.googlegr oups.com ...
And how about performance? Aren''t arithemetical operations with floats much
faster than with doubles?

"Bruce Wood" <br*******@canada.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
Waaaay回到我的大学时代,在我的数值分析课程中,我记得一个例子,其中到处使用双打(显而易见的解决方案)实际上增加了错误并给出了不如<明智地在合适的地方应用花车。

不要让我记住这个确切的例子。那是很久以前的事了。

所以,是的,即使内存不是问题,花车也有用途......
主要用于工程应用,我想。
Waaaay back in my university days, in my Numerical Analysis course, I
remember one example in which using doubles everywhere (the obvious
solution) actually increased error and gave a less precise answer than
judicious application of floats in the right places.

Don''t ask me to remember the precise example. That was a long time ago.

So, yes, even when memory is not an issue floats have their uses...
mostly for engineering applications, I would imagine.



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

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