max {f | f是一个浮点数,-f是一个浮点数,不会导致溢出} ==? [英] max{f | f is a float and -f is a float and doesn't cause overflow}== ?

查看:60
本文介绍了max {f | f是一个浮点数,-f是一个浮点数,不会导致溢出} ==?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最大浮点数f是多少,因此-f不会溢出并且

仍然可以表示为浮点数。


-

祝你好运,

亚历克斯。


PS。要给我发电子邮件,请删除loeschedies。从给出的电子邮件地址。

解决方案

Alexander Malkis写道:


什么是最大的浮点数f这样-f不会溢出,并且仍然可以表示为浮点数。



FLT_MAX,在< float.h>中定义。在不同的C实现中,这个值将是不同的b $ b,但是总是

至少为1e37。


-
Er*********@sun.com




" Alexander Malkis" <人***************** @ stone.cs.uni-sb.de> aécritdansle

message de news:c5 *********** @ hades.rz.uni-saarland.de ...

什么是最大的浮点数f,因此-f不会溢出,并且仍然可以表示为浮点数。


< float.h> header提供了许多关于浮点数

数字处理的东西。宏FLT_MIN和FLT_MAX分别代表float类型的最小et最大值的最大

值。

这些值是实现定义的。

因此,为了解答你的问题,如果f为正,-f不会溢出

直到f不超过-FLT_MIN,如果f为负,-f不会溢出直到

f没有超过-FLT_MAX。


Regis

-
致以最诚挚的问候,
Alex。

PS。要给我发电子邮件,请删除loeschedies。来自给出的电子邮件地址。



"RégisTroadec"写道:


亚历山大·马尔基斯 <人***************** @ stone.cs.uni-sb.de>一个écritdansle
消息de news:c5 *********** @ hades.rz.uni-saarland.de ...

什么是最大的浮动数字f使-f不会溢出并且仍然可以表示为浮点数。



< float.h> header提供了很多关于浮点数处理的东西。宏FLT_MIN和FLT_MAX分别代表float类型的最小值和最大值的最大值。
值是实现定义的。
因此,如果f为正,请回答您的问题,-f不会溢出
直到f不超过-FLT_MIN,如果f为负,-f不会溢出,直到
f不超过-FLT_MAX。




否;你误解了FLT_MIN:


5.2.4.2.2浮动类型的特征< float.h>

[...]

/ 10 /以下列表中给出的值应为

替换为实现的常量表达式 -

定义的(正)值小于或等于

显示的那些:

[...]

- 最小标准化正浮点数,

[...]

FLT_MIN 1E-37

恕我直言,FLT_MIN的名称在两个方面具有误导性。首先,

它看起来就像INT_MIN和LONG_MIN等等,但是

意味着它们完全不同于那些。第二,它
不一定是可区分的最小正值

从0.0f;支持非正常的实现数字

(现在大多数情况下)可以表示小于

FLT_MIN但大于零的值。但是,误导与否,

名称是标准的一部分,我们只需要通过记住它不是什么就可以处理

。 br />

-
Er ********* @ sun.com


What is the biggest float number f so that -f doesn''t overflow and is
still representable as a float.

--
Best regards,
Alex.

PS. To email me, remove "loeschedies" from the email address given.

解决方案

Alexander Malkis wrote:


What is the biggest float number f so that -f doesn''t overflow and is
still representable as a float.



FLT_MAX, defined in <float.h>. This value will be
different on different C implementations, but will always
be at least 1e37.

--
Er*********@sun.com



"Alexander Malkis" <al*****************@stone.cs.uni-sb.de> a écrit dans le
message de news:c5***********@hades.rz.uni-saarland.de...

What is the biggest float number f so that -f doesn''t overflow and is
still representable as a float.
The <float.h> header provides lots of stuff concerning floating-point
numbers handling. The macros FLT_MIN and FLT_MAX represent the largest
values respectively for the minimum et maximum values for the type float.
The values are implementation defined.
Therefore, to anwer your question, if f is positive, -f doesnt overflow
until f doesn''t exceed -FLT_MIN, if f is negative, -f doesnt overflow until
f doesn''t exceed -FLT_MAX.

Regis

--
Best regards,
Alex.

PS. To email me, remove "loeschedies" from the email address given.



"Régis Troadec" wrote:


"Alexander Malkis" <al*****************@stone.cs.uni-sb.de> a écrit dans le
message de news:c5***********@hades.rz.uni-saarland.de...

What is the biggest float number f so that -f doesn''t overflow and is
still representable as a float.



The <float.h> header provides lots of stuff concerning floating-point
numbers handling. The macros FLT_MIN and FLT_MAX represent the largest
values respectively for the minimum et maximum values for the type float.
The values are implementation defined.
Therefore, to anwer your question, if f is positive, -f doesnt overflow
until f doesn''t exceed -FLT_MIN, if f is negative, -f doesnt overflow until
f doesn''t exceed -FLT_MAX.



No; you''ve misunderstood FLT_MIN:

5.2.4.2.2 Characteristics of floating types <float.h>
[...]
/10/ The values given in the following list shall be
replaced by constant expressions with implementation-
defined (positive) values that are less than or equal
to those shown:
[...]
-- minimum normalized positive floating-point number,
[...]
FLT_MIN 1E-37

IMHO the name FLT_MIN is misleading on two counts. First,
it looks just like INT_MIN and LONG_MIN and so forth, but has
a meaning that is not at all analogous to those. Second, it
is not necessarily the minimum positive value distinguishable
from 0.0f; an implementation that supports "denormal" numbers
(most do, nowadays) can represent values that are smaller than
FLT_MIN but greater than zero. Misleading or not, though, the
name is part of the Standard and we''ll just have to deal with
it by remembering what it isn''t.

--
Er*********@sun.com


这篇关于max {f | f是一个浮点数,-f是一个浮点数,不会导致溢出} ==?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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