为什么FLT_MIN等于零? [英] Why is FLT_MIN equal to zero?

查看:832
本文介绍了为什么FLT_MIN等于零?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

limits.h中指定非浮点运算类型,例如限制 INT_MIN INT_MAX 。这些值是您可以使用一个int重新present最消极,最积极的价值观。

limits.h specifies limits for non-floating point math types, e.g. INT_MIN and INT_MAX. These values are the most negative and most positive values that you can represent using an int.

float.h时,也有 FLT_MIN 定义和 FLT_MAX 。如果你做到以下几点:

In float.h, there are definitions for FLT_MIN and FLT_MAX. If you do the following:

NSLog(@"%f %f", FLT_MIN, FLT_MAX);

您得到以下输出:

FLT_MIN = 0.000000, FLT_MAX = 340282346638528859811704183484516925440.000000

FLT_MAX 等于一个非常大的数字,如你所期望的,但为什么 FLT_MIN 等于零,而不是一个真正的大负数?

FLT_MAX is equal to a really large number, as you would expect, but why does FLT_MIN equal zero instead of a really large negative number?

推荐答案

这实际上并不是零,但它可能看起来像零,如果你检查它使用的printf 的NSLog 使用%F 。结果
float.h时(至少在Mac OS X 10.6.2), FLT_MIN 被描述为:

It's not actually zero, but it might look like zero if you inspect it using printf or NSLog by using %f.
According to float.h (at least in Mac OS X 10.6.2), FLT_MIN is described as:

/* Minimum normalized positive floating-point number, b**(emin - 1).  */

注意的的在那句话: FLT_MIN 指最低(标准化)号的大于零,的。 (有小得多非归一化数)。

Note the positive in that sentence: FLT_MIN refers to the minimum (normalized) number greater than zero. (There are much smaller non-normalized numbers).

如果你想最小浮点数(包括负数),可以使用 -FLT_MAX

If you want the minimum floating point number (including negative numbers), use -FLT_MAX.

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

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