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
浮動小数点数の話
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
kato dayo
November 27, 2018
Programming
390
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
浮動小数点数の話
kato dayo
November 27, 2018
Other Decks in Programming
See All in Programming
Long Living Tokens, Die, Die, Die! (or: The One Ring is Banned in Modern)
sylph01
0
320
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
1.1k
Railsバージョンを4倍にした話
optim
0
440
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Kaigi on Rails 2026, Tokyo, Japan
marcoroth
2
260
phperだってパンチカードでコーディングしたい
o0h
PRO
0
340
Apple Intelligence を用いた個人情報誤送信防止、及びユーザーリクエスト体験の改善について
yukiny
0
350
Vue Fes Japan の “作る側”に関わってみて
naokihaba
0
160
AWSに止められる覚悟してますか?
morizo_1984
2
540
contenteditable と日本語入力に向き合う
colorful12
0
200
Simple Storage Service(S3) is not simple
iwatsukayura
0
290
[ハンズオン]AIへの指示だけで「五目並べ」を作ってみよう
satoshi256kbyte
1
380
ソニーのクラウド共通基盤の変遷とAI時代の開発スタイルに合わせた進化 / The Journey of Sony’s Common Cloud Platform and Its Evolution for AI-Native Development
kenjiyoneyama
0
270
Featured
See All Featured
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
1
450
New Earth Scene 8
popppiees
4
2.7k
First, design no harm
axbom
PRO
2
1.3k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
300
Building Better People: How to give real-time feedback that sticks.
wjessup
371
20k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
730
Site-Speed That Sticks
csswizardry
13
1.6k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
430
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.8k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
Transcript
浮動小数点数の話 Hiroki Kato 2018/11/28 PHP勉強会
軽く自己紹介 Kato Hiroki @kato_dev C言語でデジカメ開発 組み込みOSのテクニカルサポート Webサービスのプログラマ とある会社で、web api 作ってます
PHP, Postgresql
浮動小数点数に関する出来事
環境 AWS の Redshift (PostgreSQL互換) 月次、日次レポートの値ズレてない?
float_A 19.99 29.99 39.99 とあるテーブル CAST(flot_A * 100 AS INTEGER)
浮動小数点数に100かけて、INTEGERでキャスト result 1998 2999 3999
float_A 19.99 29.99 39.99 result 1998 2999 3999 19.99 が
1998 ?
浮動小数点数って近似だっけ?
2進数での小数表現 10進数 2進数 0.5 0.1 2-1 0.25 0.01 2-2 0.3
0.010011001100110011… 0.29999999999999998889776975 近似
19.99は? 10進数 2進数 19.99 10011.11111101… 19.989999999999998436… 近似
19.99 * 100 の INTEGER型 1998.9999999999998436 の INTEGER型 小数点以下の切り捨て 1998
PHPにおいての浮動小数点数 http://php.net/manual/ja/language.types.float.php から引用 浮動小数点数の精度 浮動小数点数の精度は有限です。 … さらに、十進数では正確な小数で表せる有理数、たとえば 0.1 や 0.7
は、 二進数の浮動小数点 数としては正確に表現できません。したがって、それを内部的な二進数表現に変換する際 には、どうしても多少精度が落ちてしまいます。
<?php $a = 1.6; $b = 8 – 6.4; echo
$a == $b ? 'equal' : 'not equal'; php 7.2.12 on windows10 64bit not equal
<?php ini_set(‘precision’, 23); 浮動小数点数に関して表示される最大桁数 $a = 1.6; $b =
8 – 6.4; echo $a . "¥n"; echo $b . "¥n"; php 7.2.12 on windows10 64bit 1.6000000000000000888178 1.5999999999999996447286 $a : $b :
浮動小数点数の性質 (IEEE 754) 0に近い値は精度が高い 0から離れる程、精度が低い
<?php ini_set(‘precision’, 53); 浮動小数点数に関して表示される最大桁数 $a = pow(2, 63);
2の63乗 $b = pow(2, 63) + 1; 2の63乗+1 echo $a . "¥n"; echo $b . "¥n"; php 7.2.12 on windows10 64bit 9223372036854775808 9223372036854775808 $a : $b : 精度が悪くなる例 2の63乗 等しい pow(2, 63) + 1025 : 9223372036854777856
浮動小数点数は近似 ご清聴ありがとうございました