0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Excelが仕様15桁を超える数値を隠れて持つ件

0
Posted at

以下のコードを実行すると

Sub test()
    With Range("A1")
        .Value = 100000000000000.4999@

        Debug.Print "A1 Value : " & .Value
        ' A1 Value : 100000000000000

        Debug.Print "A1 Value2: " & .Value2
        ' A1 Value2: 100000000000000
    End With

    With Range("A2")
        .Value2 = 100000000000000.4999@

        Debug.Print "A2 Value : " & .Value
        'A2 Value : 100000000000001

        Debug.Print "A2 Value2: " & .Value2
        'A2 Value2: 100000000000001

    End With
End Sub

Excelの画面上は
image.png
となるが、

Excelの内部のxmlデータを確認すると

<sheetData>
<row r="1" spans="1:1" x14ac:dyDescent="0.4">
<c r="A1" s="1">
<v>100000000000000</v>
</c>
</row>
<row r="2" spans="1:1" x14ac:dyDescent="0.4">
<c r="A2">
<v>100000000000000.5</v>
</c>
</row>
</sheetData>

となっている。

このため、他のセルで

=A1=A2

と入力すれば、 FALSE が返ってくる。

Excelで年金財政の検証を行い巨額な給付現価や収入現価を取り扱う場合に、表示されない内部的な値によって、一致確認できないことがあるので、注意されたい。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?