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
Tadpole operators
Search
taiseiue
May 24, 2024
Programming
0
54
Tadpole operators
taiseiue
May 24, 2024
Tweet
Share
More Decks by taiseiue
See All by taiseiue
“⾞が通れるほど⼤きな”セキュリティーホールを抑えながらログインしたい
taiseiue
0
240
Kotlinのデフォルト引数の話
taiseiue
0
63
.NETの上でお手製の言語を動かす技術
taiseiue
0
89
AIの力でお手軽Chrome拡張機能作り
taiseiue
0
340
振り向き美人
taiseiue
0
22
(自作の)プログラミング言語ができるまで
taiseiue
1
460
Other Decks in Programming
See All in Programming
『毎日の移動』を支えるGoバックエンド内製開発
yutautsugi
2
290
Migration to Signals, Resource API, and NgRx Signal Store
manfredsteyer
PRO
0
120
What's new in Spring Modulith?
olivergierke
1
170
Devoxx BE - Local Development in the AI Era
kdubois
0
140
スマホから Youtube Shortsを見られないようにする
lemolatoon
27
34k
EMこそClaude Codeでコード調査しよう
shibayu36
0
420
「ちょっと古いから」って避けてた技術書、今だからこそ読もう
mottyzzz
12
7.2k
Building, Deploying, and Monitoring Ruby Web Applications with Falcon (Kaigi on Rails 2025)
ioquatix
4
2.5k
エンジニアインターン「Treasure」とHonoの2年、そして未来へ / Our Journey with Hono Two Years at Treasure and Beyond
carta_engineering
0
430
Introduce Hono CLI
yusukebe
6
3.1k
SwiftDataを使って10万件のデータを読み書きする
akidon0000
0
240
オープンソースソフトウェアへの解像度🔬
utam0k
17
3.1k
Featured
See All Featured
Imperfection Machines: The Place of Print at Facebook
scottboms
269
13k
The Illustrated Children's Guide to Kubernetes
chrisshort
49
51k
Rebuilding a faster, lazier Slack
samanthasiow
84
9.2k
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
Producing Creativity
orderedlist
PRO
347
40k
4 Signs Your Business is Dying
shpigford
185
22k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Principles of Awesome APIs and How to Build Them.
keavy
127
17k
YesSQL, Process and Tooling at Scale
rocio
173
15k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3k
Designing for humans not robots
tammielis
254
26k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
Transcript
Tadpole operators ⾮変インクリメント/デクリメント
Tadpole Operators†とは? • 副作⽤を起こさないインクリメント/デクリメントのこと • ⽇本語では⾮変インクリメント / ⾮変デクリメント • ⾒た⽬からtadpole(おたまじゃくし)演算⼦とも
値が書きかわらない 演算⼦ 同じ意味の式 意味 -~x X + 1 Xに向かって値が⼊って いくイメージ ~-x X - 1 Xから値が出ていく イメージ †https://devblogs.microsoft.com/oldnewthing/20150525-00/?p=45044
Tadpole Operators:利点 • 単項演算⼦なので優先順位が⾼い • (x + 1) * (x
- 1) なら -~x * ~-x と書ける • インクリメント/デクリメントと違い副作⽤がない
ネタバラシ シンキングタイムいる?
ネタバラシ • 本当は`~`(ビット反転)と`-`(符号反転)の組み合わせ • かっこで整理すると ‒(~x)、~(-x)に -(~x) == x+1 ~x
+ 1 == -x を常に満たす x + ~x + 1 == 0 X=5 0101 0011 Y=~X +1010 1100 Z=X+Y 1111 1111 α=Z+1 + 1 β 1 0000 0000 ビット 反転 移項 β α