次正规浮点数 [英] subnormal floating point numbers

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

问题描述

大家好,

首先我请你原谅如果之前已经问过这个问题

,但我在过去的帖子中找不到任何内容。

我写了一段应该是非常便携的代码,

并且使用了很多fp数字。在PPC cpu上一切顺利,但在某些x86 CPU上,我的性能大幅下降。经过一些

的调查后我发现这个问题是由于一些

数字变得不正常,PPC cpus似乎在静静地对待它们

没有任何明显的速度损失,而在某些x86 CPU上我得到的确是非常差的结果,只要这些奇怪的实体开始弹出

...

有人知道是否有办法禁用次正常浮动

点数,可能使用标准c / c ++ libs?我不需要它们和

对我来说,将一小部分数量降到零也是可以的 -

实际上,代码是隐含地写的非常小的

数字最终将变为零。

我希望有一个简单的问题解决方案,除了

审查任何非常单一的如果(不正常......)或其他任何事情,那么代码行和投入很多

...


提前给所有可以/将会的人帮助我...

Hi all,
first of all I beg your pardon if this question has been asked
before, but I was unable to find anything in the past posts.
I have written a piece of code that was supposed to be quite portable,
and uses a lot fp numbers. Everything goes well on PPC cpus, but on
some x86 CPU I get a dramatic loss of performance. After some
investigations I''ve discovered that the problem is caused by some
numbers becoming subnormal, PPC cpus seems to treat them quietly
without any significant loss of speed whereas on some x86 CPU I get
really very poor results as soon as these "strange" entities begin to
pop out...
Does someone know if there is a way to disable subnormal floating
point numbers, maybe using standard c/c++ libs? I don''t need them and
for me it will be just ok to have a small quantity dropped to zero -
in fact, the code is written assuming implicitly that very small
number will eventually become zero.
I hope that there is a simple solution for the problem, apart from
reviewing any very single line of code and putting a lot of
if(issubnormal...) or whatever else...

Thanx in advance to everybody that can/will help me...

推荐答案

5月15日下午3:27,终极战士< ultimatecodewarr ... @ yahoo.it> ;

写道:
On May 15, 3:27 pm, ultimatewarrior <ultimatecodewarr...@yahoo.it>
wrote:

首先,如果有人问过这个问题,请原谅

之前,但是我在过去的帖子中找不到任何东西。

我写了一段应该是非常便携的代码,

并且使用了很多fp数字。在PPC cpu上一切顺利,但在某些x86 CPU上,我的性能大幅下降。经过一些

的调查后我发现这个问题是由于一些

数字变得不正常,PPC cpus似乎在静静地对待它们

没有任何明显的速度损失,而在某些x86 CPU上我得到的确是非常差的结果,只要这些奇怪的实体开始弹出

...

有人知道是否有办法禁用次正常浮动

点数,可能使用标准c / c ++ libs?我不需要它们和

对我来说,将一小部分数量降到零也是可以的 -

实际上,代码是隐含地写的非常小的

数字最终将变为零。

我希望有一个简单的问题解决方案,除了

审查任何非常单一的如果(不正常......)或其他什么......代码行和代码很多

...
first of all I beg your pardon if this question has been asked
before, but I was unable to find anything in the past posts.
I have written a piece of code that was supposed to be quite portable,
and uses a lot fp numbers. Everything goes well on PPC cpus, but on
some x86 CPU I get a dramatic loss of performance. After some
investigations I''ve discovered that the problem is caused by some
numbers becoming subnormal, PPC cpus seems to treat them quietly
without any significant loss of speed whereas on some x86 CPU I get
really very poor results as soon as these "strange" entities begin to
pop out...
Does someone know if there is a way to disable subnormal floating
point numbers, maybe using standard c/c++ libs? I don''t need them and
for me it will be just ok to have a small quantity dropped to zero -
in fact, the code is written assuming implicitly that very small
number will eventually become zero.
I hope that there is a simple solution for the problem, apart from
reviewing any very single line of code and putting a lot of
if(issubnormal...) or whatever else...



我不是相信有任何标准可以实现这一点。我想

你正在寻找一个编译器开关(例如,在Sun C ++上的-fn)。你需要在与你的编译器相关的小组中询问。


干杯! --M

I don''t believe there is anything standard to effect this. I think
you''re looking for a compiler switch (e.g., -fn on Sun C++). You
should ask in a group related to your compiler.

Cheers! --M


ultimatewarrior写道:
ultimatewarrior wrote:

有人知道是否有办法禁用次正常浮动

点数,可能使用标准的c / c ++库?
Does someone know if there is a way to disable subnormal floating
point numbers, maybe using standard c/c++ libs?



只需将subnormal指定给double变量就应该强制它为0.


---

Walter Bright

Digital Mars C,C ++,D编程语言编译器

Just assigning the subnormal to a double variable should force it to 0.

---
Walter Bright
Digital Mars C, C++, D programming language compilers


Walter Bright写道:
Walter Bright wrote:

ultimatewarrior写道:
ultimatewarrior wrote:

>有人知道是否有办法禁用次正常浮点数,也许使用标准的c / c ++库?
>Does someone know if there is a way to disable subnormal floating
point numbers, maybe using standard c/c++ libs?



只需将subnormal指定为double变量就应该强制为0.


Just assigning the subnormal to a double variable should force it to 0.



如果subnormal不对不会传播,这不会解决问题,

会吗?


问候,


Zeppe

If the subnormal doesn''t propagate, this wouldn''t solve the problem,
would it?

Regards,

Zeppe


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

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