- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在什么实际情况下,c++ std::numeric_limits<float>::lowest()
不等于std::numeric_limits<float>::max()
的负数 ?
最佳答案
std::numeric_limits<float>::lowest()
将等于 std::numeric_limits<float>::max()
的负数如果浮点表示使用 signed magnitude ,因为最大值和最小值将具有相同的有效数字(忽略符号位)和指数,两者都包含它们的最大值。然后符号位将确定数字是正数还是负数,并且不会影响其大小。 (另一个后果是底层表示将能够表示正零和负零。)IEEE 754 使用带符号的幅度表示,因此这是您在实践中最有可能遇到的情况。
但是,另一种表示是使用 two's complement有效数。二进制补码的一个属性是最大负值的幅度大于最大正值,因此对于使用二进制补码有效数的浮点表示,std::numeric_limits<float>::lowest()
不会等于std::numeric_limits<float>::max()
的负数. IBM 1130 是使用二进制补码有效数字浮点格式的实际系统示例。 ,大约在 1970 年。
现在,cppreference.com状态:
While it's not true for fundamental C++ floating-poing types, a third-party floating-point type T may exist such that
std::numeric_limits<T>::lowest() != -std::numeric_limits<T>::max()
.
但我不确定该声明的基础是什么,因为 C++11 标准第 18.3.2.4 段仅指定了 lowest()
是:
A finite value
x
such that there is no other finite valuey
wherey < x
.Meaningful for all specializations in which
is_bounded != false
.
它还在脚注中指出:
lowest()
is necessary because not all floating-point representations have a smallest (most negative) value that is the negative of the largest (most positive) finite value.
因此,C++ 实现似乎可以使用二进制补码浮点表示形式,并且有 std::numeric_limits<float>::lowest()
。不等于 std::numeric_limits<float>::max()
的负数.
关于c++ - Float Lowest 和 Max 的数值限制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42405800/
我正在开发一个 Java 脚本,为此我需要正则表达式来检查文本框中输入的文本是否应该是字母和数值的组合。 我尝试了 Java 脚本的 NaN 函数,但字符串的最小长度和最大长度应为 4,并以字母作为第
我给出了两个长方体,其中只有一个轴对齐(另外两个不需要对齐)和顶点坐标(在全局坐标系中),我知道它们相交。我正在寻找一种可以计算路口体积的算法。 为了检查交点,我使用了分离轴定理。 最佳答案 可以通过
我有一个类似这样的对象的 json 列表 [{ "something": "bla", "id": 2 }, { "something": "yes", "id": 1
这是一篇很长的文章,但请留在我身边... 我有一个字典,它将“PO”保存为Key,将“SO”保存为项目(在某些情况下,某个“PO”可能有多个“SO”) . 工作表中的我的 Excel 数据,字典在其中
我的问题是是否有办法使用 terms include在 numeric field在 elasticsearch aggregation . 我在 Elasticsearch 中对多个字段使用通用查询
我有一个 perl 代码片段 use JSON::XS; $a = {"john" => "123", "mary" => "456"}; print encode_json($a),"\n"; 输出
我想对 python 进行一个条件测试,以检查给定输入数字的值是否等于或小于 9,并且大于或等于 0。 number =input( "Please enter a number! :" ) Plea
我有一个这样的对象: var rock = { 5: 0.5, 0: 0.8, 10: 0.3, 2: 1.0, } 我有一个像 4.3 这样的数字,我需要前后数字的索引和值。在这个例子中我会
对于 iOS 中的 Objective-C: 如果我有一个字符串,如何读取单个字符的 unicode 数值? 例如,如果我的字符串是:“Δ”,unicode 字符是 U+0394,那么我如何读取该字符
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,
我有这样的数组 var arrayVal_Int = ["21", "53", "92", "79"]; var arrayVal_Alpha = ["John", "Christine", "L
就像标题暗示我需要做这样的事情...... $i++;//we all know this. $value = 'a'; increment($value);// i need this functi
我有一个文件,其中包含一些不同值的概率,例如: 1 0.1 2 0.05 3 0.05 4 0.2 5 0.4 6 0.2 我想使用此分布生成随机数。是否存在处理此问题的现有模块?自己编写代码相当简单
因此,我在从使用 RCPP 创建的函数返回值时遇到了一些问题。它只返回 NumericVector 的第一个值。问题是当我在自身内部调用函数并将 NumericVector 传递回 out 变量时。任
我有下面的数字 vector 模板类(用于数值计算的 vector )。我正在尝试使编写 D=A+B+C 成为可能,其中所有变量都是 Vector 对象。 A、B 和 C 不应修改。我的想法是使用 V
本文实例讲述了mysql常用函数。分享给大家供大家参考,具体如下: 本文内容: mysql函数的介绍 聚集函数 avg count max
我正在尝试使用 python(无关)为我的公司自动化一些事情,这就是我的问题。首先,我正在从邮箱中的特定文件夹创建数据框。(到这里没问题)” RangeIndex: 36 entries, 0 to
我在让 Angular ng-if 工作时遇到了一些麻烦。我希望我的 DOM 元素之一在 $scope.week = 1 时消失。 在我的 Controller 中我设置了 $scope.week =
我正在阅读 Ingersoll、Morton 和 Farris 撰写的 Taming Text,但我不明白 solr 的数字 trie 实现如何帮助搜索文本?我对 solr.TrieField fie
这个问题已经有答案了: What is the difference between client-side and server-side programming? (3 个回答) 已关闭 9 年前
我是一名优秀的程序员,十分优秀!