Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Not a Number of Floating Point Problems
Search
tyabu12
July 11, 2018
Research
70
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Not a Number of Floating Point Problems
G. T. Leavens
March 2006, Journal of Object Technology 5(2):75-83.
tyabu12
July 11, 2018
More Decks by tyabu12
See All by tyabu12
Git セミナー
tyabu12
0
59
Type-Safe Modular Hash-Consing (Chapter 2)
tyabu12
0
61
Automating the Verification of Floating-Point Programs
tyabu12
0
67
福井大学 情報・メディア学科 学士 研究発表
tyabu12
0
36
Other Decks in Research
See All in Research
就労支援の現場での生成AI活用
enochan
0
150
20260624 NLP colloquium: 単一のhubテキストがCLIPを壊す:hubnessによる埋め込みの脆弱性特定
de9uch1
2
300
Language and AI
ayaniwa
0
320
JICA QUEST 共創×革新プログラム Impact Report(海ノ向こうコーヒー)
ontheslope
0
840
実例から見るLLMのマンガ理解:実務VQAタスクによる長期的文脈と視覚情報の定性評価
kzmssk
0
190
[最先端NLP勉強会2026] Agentic Rubrics as Contextual Verifiers for SWE Agents
rfujii
1
390
Physical AIでモデリングはどう変わるか/How Physical AI Will Change Modeling
stktu
0
300
PHTalks Bengaluru - SSRF When All Else Fails
dk999
0
1.2k
湯村研究室の紹介2026 / yumulab2026
yumulab
0
130
HackSick vol.7 LT資料【LLMアーキテクチャ入門・事前学習時の躓き所解説】 スパースなAttention・状態空間モデル
rikkabotan7
0
220
TESSERA: Temporal Embeddings of Surface Spectra for Earth Representation and Analysis
satai
3
120
MM-OVSeg: Multimodal Optical–SAR Fusion for Open-Vocabulary Segmentation in Remote Sensing
satai
3
160
Featured
See All Featured
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
280
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.7k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
480
Making Projects Easy
brettharned
120
6.8k
The Cost Of JavaScript in 2023
addyosmani
55
10k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
58k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
940
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.8k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.9k
Are puppies a ranking factor?
jonoalderson
2
4.1k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
3.4k
Deep Space Network (abreviated)
tonyrice
0
370
Transcript
Not a Number of Floating Point Problems G. T. Leavens.:
March 2006, Journal of Object Technology 5(2):75‑83. 2018年 7月 11日 @tyabu12
1. (浮動小数点数の) 標準化の背景 多くの言語の浮動小数点数は IEEE 754 標準を採用 2
NaN IEEE‑754 で定義されている、"未定義" (Not a Number) を表す値 0.0/0.0 = NaN
log(−3.14) = NaN x + NaN = NaN 3
2. NaN に関する問題 NaN < NaN の結果はどうすべきか? 論理値には true か
false しかない true でも false でもない → 例外機構を使う? しかし例外機構を全ての言語持っているわけではない → 標準には組み込めない 4
片側が NaN の場合の比較演算の定義 (IEEE 754) 以下, ∀x.x ≠ NaN とする
式 評価 NaN ≠ x true NaN = x false NaN < x false NaN > x false NaN ≤ x false NaN ≥ x false 5
形式手法における IEEE 754 の問題点 6
等価性が成り立たない 形式手法は数学に基づく 等価性という最も基本的な属性は、 "reflexive" つまり ∀x.x = x をい う
しかし、IEEE 754 が定義する NaN ではこの等価が成り立たない → NaN = NaN の評価は false である 7
全順序でない IEEE 754 が定義する NaN では三分律が成り立たない (2つ前のスライ ド) 三分律 (trichotomy
law) : x < y ∨ x = y ∨ x > y が成り立つこと この違反は, 浮動小数点数はもはや全順序でないことを意味する しかし NaN が "Not a Number" であることを考慮すれば, これは理にか なっている (Number は全順序になっている) 問題は, 型システムが NaN を数字と見なしてしまうこと 8
3 平均計算プログラムの検証例 Java と JML を用いた, 浮動小数点数を用いたプログラムの検証例 NaN による障害をどう取り除きながら, 事前・事後条件をアノテー
ションしていくかを順を追って解説 基本的には NaN で場合分けしている 特に目新しい記述はないので, 省略 9
4. NaN の矛盾の解決法 10
1. 論理値に第三の値 NaB (Not a Boolean) を許す メリット 全ての値の比較について定義できる デメリット
現在のプログラミング言語や定理証明では一般的ではない 全ての型 T に "Not a T" が必要になる 例: (NaB ? 1 : 2) の条件式の評価は "Not a Integer" 11
2. 言語から NaN を追放する ビルトイン演算やユーザー定義関数は, NaN を返す代わりに, 例外を投げ る メリット
言語の簡潔化 整数演算との調和 プログラマは例外処理に馴染みがある デメリット 効率性の損失 12
二案の中間案1. 例外を起こすか NaN を返すかをきりかえる, スイッ チ, グローバルパラメータ, オプション しかし一旦 NaN
が言語の一部になったら, NaN 値がたとえ禁じられたと しても考慮する必要がある 結局仕様などの観点から嬉しくない 13
二案の中間案2. 値としての NaN は許容するが, 標準の浮動小数点数 型には許容しない Java だと, double 型や
float 型は NaN を含まず, doubleWithNan ( double + NaN) 型や floatWithNaN ( float + NaN) 型を用意する NaN でないなら, doubleWithNan を double にキャストすることが 可能 前半で述べた反射等価性の欠如問題から, doubleWithNan 型には == や != 演算を定義しない 14
5. 結論 浮動小数点数にかかわる仕様を書く際は, いつも以上に気をつける必要が ある (特に値としての NaN の可能性の考慮) 完結で安定したアプローチは, 値としての
NaN を使う代わりに例外を投 げることである もし値としての NaN を維持したいなら, 型システムは落とし穴を避ける よう調節することができる 結果としてより複雑になるが, 一般的なケースで仕様はかなり簡潔 になるだろう これは最終的にはプログラマを助け, より信頼できる言語へと至る だろう 15