Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
小数の丸め誤差の話
Search
circled9
July 26, 2024
Programming
0
140
小数の丸め誤差の話
Niigata5分Tech #10の発表資料です。
https://niigata-5min-tech.connpass.com/event/324842/
circled9
July 26, 2024
Tweet
Share
More Decks by circled9
See All by circled9
キースイッチ入門
circled9
0
73
CloudflareのAI関連の機能さわってみた
circled9
0
590
0.0.0.0 day
circled9
0
100
数値の文字列をパースしよう
circled9
0
220
🔥 Hono v4 やってみた
circled9
1
190
JetBrains AI Assistant を試してみた
circled9
1
520
Fresh
circled9
0
240
React Hooks 勉強会 vol.3
circled9
2
440
JSON.stringify()
circled9
2
490
Other Decks in Programming
See All in Programming
TypeScript LSP の今までとこれから
quramy
1
500
UPDATEがシステムを複雑にする? イミュータブルデータモデルのすすめ
shimomura
1
550
つよそうにふるまい、つよい成果を出すのなら、つよいのかもしれない
irof
1
290
Passkeys for Java Developers
ynojima
3
860
SODA - FACT BOOK
sodainc
1
930
AIエージェントによるテストフレームワーク Arbigent
takahirom
0
380
実践ArchUnit ~実例による検証パターンの紹介~
ogiwarat
2
260
Gleamという選択肢
comamoca
6
720
機械学習って何? 5分で解説頑張ってみる
kuroneko2828
0
210
ReadMoreTextView
fornewid
1
420
CSC307 Lecture 17
javiergs
PRO
0
110
Webからモバイルへ Vue.js × Capacitor 活用事例
naokihaba
0
670
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
92
6.1k
The Straight Up "How To Draw Better" Workshop
denniskardys
233
140k
Why Our Code Smells
bkeepers
PRO
337
57k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
8
660
Done Done
chrislema
184
16k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Making Projects Easy
brettharned
116
6.2k
What's in a price? How to price your products and services
michaelherold
245
12k
Mobile First: as difficult as doing things right
swwweet
223
9.7k
Practical Orchestrator
shlominoach
188
11k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
47
2.8k
Transcript
খͷؙΊޡࠩͷ Niigata 5min Tech #10 @circled9 1
ࣗݾհ @circled9 দҪɹਖ਼ࢤ / Matsui Masashi גࣜձࣾϞχΫϧ جຊใٕज़ऀͷࢿ֨͋Γ·͕͢ هԱ͋Γ·ͤΜ 2
ࠓখͷؙΊޡࠩͷΛ͠·͢ 3
Node.js 4
Ͳ͏ͯ͠ʁ • ଟ͘ͷϓϩάϥϛϯάݴޠɺ෦తʹΛೋਐͰѻ͍ͬͯΔ • ेਐͷখΛೋਐʹม͢Δͱޡ͕ࠩੜ͡Δ߹͕͋Δ • Ή͠Ζޡ͕ࠩग़ͳ͍ํ͕গͳ͍ͷͰ...? 5
ेਐͷখΛೋਐͰද͢ͷ͍͠ • ೋਐͷͷNܻ2ͷN-1ͷ 1 1 1 1 = 15 8
4 2 1 • ҰํɺೋਐͷখͷNܻ2ͷϚΠφεN-1ͷ 0. 1 1 1 = 0.5 + 0.25 + 0.125 = 0.875 1 1/2 1/4 1/8 • 2ͷϚΠφεNͷΈ߹ΘͤͰਖ਼֬ʹදݱͰ͖Δʹݶք͕͋Δ 6
Node.js 7
Ͳ͏͢ΕޡࠩΛ͛Δ͔ • খͷܭࢉΛͯ͠େৎͳܕͳͲΛ͏ • খͰͳ͘ͷܭࢉʹ͢Δ 8
খͷܭࢉΛͯ͠େৎͳܕͳͲΛ͏ • C#ͷ߹decimalܕ͕͋Δ • Pythonͷ߹decimalϞδϡʔϧ͕͋Δ • JavaScriptͷ߹big.jsͳͲͷϥΠϒϥϦ͕͋Δ 9
Python 10
খͰͳ͘ͷܭࢉʹ͢Δ • ܭࢉ͢Δલʹʹͯ͠ɺܭࢉޙʹখʹ͢ • ྫ͑100Λ͔͚ͯɺ࠷ޙʹ100ͰׂΔ • ((0.1 * 100) +
(0.2 * 100)) / 100 • ͜ͷ߹ɺܭࢉରͷͷܻΛؾʹ͢Δඞཁ͕͋Δ 11
Node.js 12
·ͱΊ • ଟ͘ͷϓϩάϥϛϯάݴޠͰɺখͷܭࢉͰޡ͕ࠩൃੜ͢Δ • ޡࠩΛग़͞ͳ͍Α͏ʹ͢ΔʹదͳରԠΛ͢Δඞཁ͕͋Δ 13
ଟ͘ͷϓϩάϥϛϯάݴޠʁ 14
খͷܭࢉͰޡࠩͷग़ͳ͍ϓϩάϥϛϯάݴޠ • COBOL • Ada • MSX-BASIC • etc... දݱʹBCDΛ͏ͷ͕ϙΠϯτͬΆ͍
15
BCD • Binary-Coded DecimalɺೋਐԽेਐ • ೋਐ4ܻ͋Ε0͔Β15·ͰͷΛදͤΔͷͰɺ0͔Β9Λͬ ͯेਐͷҰܻΛදݱ͢Δ • ྫ͑ेਐͷ26ɺBCDͰ 0010
0110 ʹͳΔ • BCDجຊใٕज़ऀࢼݧͷࢼݧൣғʹؚ·Ε͍ͯΔ 16
BCDجຊใٕज़ऀࢼݧͷ ࢼݧൣғʹؚ·Ε͍ͯΔ 17
શʹΕͯͨͱ͍͏͔ ֮͑ͨهԱ͢Βͳ͍😇 18
Goݴޠ 19
20
https://go.dev/ref/spec#Constant_expressions υΩϡϝϯτᐌ͘ ఆࣜৗʹਖ਼֬ʹධՁ͞Ε·͢ Constant expressions are always evaluated exactly; 21
22
͓͠·͍ 23
ࢀߟࢿྉ • খΛѻ͏ͳΒBCDΛ࠾༻͍ͯ͠Δݴޠ͕ѹత • https://qiita.com/ma2shita/items/d8aeec9e2921dc3536f4 24