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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
論文読み会 SNLP2026 Tau2-Bench: Evaluating Conversational Agents in a Dual-Control Environment
s_mizuki_nlp
0
300
【Zozo Research 技術共有会】三次元領域の現在と展望
mickey_0226
3
680
Karkada さんの論文 × 2 の紹介: (1) Closed-Form Training Dynamics Reveal Learned Features and Linear Structure in Word2Vec-like Models, (2) Symmetry in language statistics shapes the geometry of model representations
eumesy
PRO
1
860
湯村研究室の紹介2026 / yumulab2026
yumulab
0
130
Cross-Media Human-Information Interaction
signer
PRO
0
280
Santé et fertilité des sols : ce que nous disent les pratiques dans les systèmes de polyculture-élevage
institutdelelevage
PRO
0
120
全国町字単位空き家率推定データver1.0データ仕様
microbaseinc
0
290
Les émissions de méthane entérique en élevage laitier : Enjeux et travaux menés en Afrique de l’Ouest et en France
institutdelelevage
PRO
0
130
【ローカルAIに向き合う展示会vol.2】液体時間定数型モジュールを用いた オリジナルの双方向エンコーダーモデルNexteraBERT 推論速度向上検討並びにダウンストリーム評価
rikkabotan7
0
230
第64回CV・PRML勉強会 論文紹介:Linguistic Priors for Visual Decoupling: Towards Symmetric Vision-Brain Alignment
sokikatayama
0
250
実例から見るLLMのマンガ理解:実務VQAタスクによる長期的文脈と視覚情報の定性評価
kzmssk
0
190
Bilan travail en élevage : première restitution des enquêtes 2025-2026
institutdelelevage
PRO
0
230
Featured
See All Featured
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.9k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.4k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
590
Ten Tips & Tricks for a 🌱 transition
stuffmc
1
270
Designing Experiences People Love
moore
143
24k
GraphQLとの向き合い方2022年版
quramy
50
15k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
730
Practical Orchestrator
shlominoach
192
12k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
20k
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