5

簡単な質問: 数値 1.15507e-173 の倍精度での正しいビット表現は何ですか? 完全な質問: この数値の正しい解析をどのように判断しますか?

背景:私の質問は、3つの異なるパーサーからの2つの異なるビット表現を示すこの回答から続きます。

0x1c06dace8bda0ee0

0x1c06dace8bda0edf

そして、どのパーサーが正しいのか疑問に思っています。

C99 仕様の更新セクション 6.4.4.2では、C パーサーについて、

"...the result is either the nearest representable value, or the larger
or smaller representable value immediately adjacent to the nearest
representable value, chosen in an implementation-defined manner."

これは、解析された数値が最も近い数値である必要はなく、2 つの隣接する表現可能な数値の 1 つである必要もないことを意味します。7.20.1.3 の同じ仕様によると、strtod() は本質的に組み込みパーサーと同じように動作します。これを指摘してくれた回答者に感謝します。

同様の質問に対するこの回答と、このブログも参照してください。

4

1 に答える 1

1
:= num1 =ImportString["\。1c\.06 \ .da \ .ce \ .8b \.da\。0e\.e0"、 "Real64"、ByteOrdering->1]//最初;
:= num2 =ImportString["\。1c\.06 \ .da \ .ce \ .8b \.da\。0e\.df"、 "Real64"、ByteOrdering->1]//最初;
:= SetPrecision [num1、Infinity]-numOr // N
:= numOr = SetPrecision [1.15507、Infinity] * 10 ^ -173;
             -190
= -6.65645 10
:= SetPrecision [num2、Infinity]-numOr // N
             -189
= -2.46118 10

両方が同じ側にずれていることを考えると、正しい表現が最初のものであるということになります。

于 2011-08-03T10:37:49.317 に答える