-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
問題
Vim script で float 型変数を等値比較する際、内部では単純に x == y としているが、誤差を考慮しなくてよいか?
:echo 0.1+0.2 == 0.15+0.15
" 0
:let x = 1.0
:let x += 0.001
:let x -= 0.001
:echo x == 1.0
" 0Vim 内部で誤差評価する (float_equal())
vim/vim@master...ichizok:fix/float_equal
あるいは、Vim script に誤差評価用の関数 (isclose(x, y) のような) や定数を追加する。