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
JavaScriptは少数が苦手
Search
kurosuke
October 30, 2022
Programming
44
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
JavaScriptは少数が苦手
2022/2/22 はじめてのIT勉強会(仙台)
kurosuke
October 30, 2022
More Decks by kurosuke
See All by kurosuke
面白楽しいIT用語
kurosuke
0
46
Other Decks in Programming
See All in Programming
Event is what happens
moro
2
770
GemmaをJevのように使ってみる / Use Gemma like Jev
kishida
5
790
AI主導のプログラミング学習アプリを作ってみた
econanringo
0
180
ソニーのクラウド共通基盤の変遷とAI時代の開発スタイルに合わせた進化 / The Journey of Sony’s Common Cloud Platform and Its Evolution for AI-Native Development
kenjiyoneyama
0
270
AmebaブログはKMPから卒業します
kmars0605
0
180
残高管理から台帳サービスへの進化
artoy
1
200
全ての永続トークンを、生まれる前に消し去りたい!
sylph01
2
880
ActionController meets Protocol Buffers
sorah
0
520
Jetpack Compose Mechanisms
skydoves
3
820
見えないものを探る要求要件定義に必要な基本的思考 / invisible-requirement-thinking
minodriven
15
8.5k
カツオ、ご期待ください
suneo3476
0
190
phperだってパンチカードでコーディングしたい
o0h
PRO
0
330
Featured
See All Featured
Statistics for Hackers
jakevdp
799
230k
Skip the Path - Find Your Career Trail
mkilby
1
260
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.1k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
2
6.3k
We Are The Robots
honzajavorek
0
400
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
410
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
300
SEO for Brand Visibility & Recognition
aleyda
0
4.8k
The Invisible Side of Design
smashingmag
301
52k
Facilitating Awesome Meetings
lara
57
7.2k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3.2k
Become a Pro
speakerdeck
PRO
31
6.3k
Transcript
JavaScriptখ͕ۤख ʙුಈখܭࢉਖ਼֬ʹͰ͖ͳ͍ʙ 2022/2/22ɹגࣜձࣾBTMɹੴࠇ
0.3 - 0.1 = ?
console.log( 0.3 - 0.1 ) > 0.19999999999999998
·͔͡ɺJavaScript... σΩΔࢠͩͱࢥ͍ͬͯͨͷʹ...
JavaScriptͰখΛͬͨܭࢉཁҙ • ޡࠩͷݪҼɹ ɹ 10ਐͷখ 2ਐʹ͏·͘ม͕Ͱ͖ͳ͍ͱ͖͕͋Δ͔Β ɹ(͖ͬ͞ͷྫ)ɹ0.2 Λ2ਐมɹɹ0.00110011.....ʢ॥খʣ • JavaScriptͷNumberܕ
ɹුಈখʢIEEE754ʣΛ࠾༻
࣮ࡍʹ͋ͬͨࠔͬͨ ͱ͋Δ͓٬༷ͷCRMʢސ٬ཧγεςϜʣͰ ߹ܭֹۚʢ੫ࠐʣͷֹ͕ۚ߹Θͳ͍
ͲΜͳܭࢉʁ ߹ܭֹۚʢ੫ࠐʣ͕߹Θͳ͍ ߹ܭֹۚ(੫ൈ) ফඅ੫ֹ(10%) ߹ܭֹۚ(੫ࠐ) : 3,000,000ԁ : 300,000ԁ :
3,300,000ԁ Α͋͘Δ՝੫ܭࢉͰ͢
ͲΜͳ෩ʹ߹Θͳ͔ͬͨͷʁ ߹ܭֹۚʢ੫ࠐʣ͕߹Θͳ͍ Math.ceil(3000000 * 1.1) > 3300001 ߹ܭֹۚ(੫ൈ) ফඅ੫ֹ(10%) ߹ܭֹۚ(੫ࠐ)
: 3,000,000ԁ : 300,000ԁ : 3,300,000ԁ
ͲΜͳ෩ʹ߹Θͳ͔ͬͨͷʁ ߹ܭֹۚʢ੫ࠐʣ͕߹Θͳ͍ Math.ceil(3000000 * 1.1) > 3300001 ߹ܭֹۚ(੫ൈ) ফඅ੫ֹ(10%) ߹ܭֹۚ(੫ࠐ)
: 3,000,000ԁ : 300,000ԁ : 3,300,000ԁ ̍ԁͣΕͨɾɾɾ 3,300,001ԁ
ͳͥ߹Θͳ͔ͬͨͷʁ ߹ܭֹۚʢ੫ࠐʣ͕߹Θͳ͍ Math.ceil (3000000 * 1.1) > 3300001 // NG
A . গͷޡࠩʴؙΊॲཧͷ͍ͤͰ͢ খΛΓ্͛ͯʹ͢Δ 3300000.0000000005
Ͳ͏͢Εྑ͔ͬͨʁ ߹ܭֹۚʢ੫ࠐʣ͕߹Θͳ͍ Math.ceil (3000000 * 110 / 100) > 3300000
// OK A . ʢҊͦͷ̍ʣܭࢉʹখΛΘͳ͍ 3300000
Ͳ͏͢Εྑ͔ͬͨʁ ߹ܭֹۚʢ੫ࠐʣ͕߹Θͳ͍ Math.ceil(BigNumber(3000000).times(1.1)) > 3300000 // OK A . ʢҊͦͷ̎ʣখܭࢉ༻ϥΠϒϥϦΛ༻͢Δ
3300000 bignumber.jsΛͬͨྫ
ුಈখ(floatdouble)Ͱͳ͍ܕΫϥεΛ͓͏ ଞͷݴޠʁ Java Ruby MySQL BigDecimal BigDecimal DECIMAL, NUMERIC
খΛؚΉܭࢉਖ਼֬ͳ݁Ռ͕ग़ͳ͍͜ͱ͕͋Δ ·ͱΊ ͳΔ͘ʹஔ͖͑ͯܭࢉ͢Δ ුಈখͰͳ͘ݻఆখͷܕΫϥεΛ͏ ͍͟ͱͳͬͨΒখܭࢉ༻ͷϥΠϒϥϦͳͲ༻Λݕ౼ 0.3 - 0.1 number, float,
double ( 3 - 1 ) / 10 decimalܥ JavaScriptͳΒbignumber.jsdecimal.js
͜ΕͰ͏ɺখܭࢉා͘ͳ͍Ͱ͢Ͷʂ ऴΘΔલʹͪΐͬͱ͚ͩએ...
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠