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
49
Tadpole operators
taiseiue
May 24, 2024
Tweet
Share
More Decks by taiseiue
See All by taiseiue
“⾞が通れるほど⼤きな”セキュリティーホールを抑えながらログインしたい
taiseiue
0
170
Kotlinのデフォルト引数の話
taiseiue
0
40
.NETの上でお手製の言語を動かす技術
taiseiue
0
60
AIの力でお手軽Chrome拡張機能作り
taiseiue
0
280
振り向き美人
taiseiue
0
19
(自作の)プログラミング言語ができるまで
taiseiue
1
340
Other Decks in Programming
See All in Programming
Cursor AI Agentと伴走する アプリケーションの高速リプレイス
daisuketakeda
1
110
Create a website using Spatial Web
akkeylab
0
260
複数アプリケーションを育てていくための共通化戦略
irof
10
3.8k
「ElixirでIoT!!」のこれまでとこれから
takasehideki
0
350
無関心の谷
kanayannet
0
160
つよそうにふるまい、つよい成果を出すのなら、つよいのかもしれない
irof
1
280
CSC307 Lecture 17
javiergs
PRO
0
110
事業戦略を理解してソフトウェアを設計する
masuda220
PRO
21
5.9k
Haskell でアルゴリズムを抽象化する / 関数型言語で競技プログラミング
naoya
16
4k
XSLTで作るBrainfuck処理系
makki_d
0
190
Use Perl as Better Shell Script
karupanerura
0
690
eBPFを用いたAIネットワーク監視システム論文の実装 / eBPF Japan Meetup #4
yuukit
3
750
Featured
See All Featured
Building Flexible Design Systems
yeseniaperezcruz
328
39k
Intergalactic Javascript Robots from Outer Space
tanoku
271
27k
The Cost Of JavaScript in 2023
addyosmani
50
8.3k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
137
34k
A Tale of Four Properties
chriscoyier
159
23k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
14
1.5k
Making the Leap to Tech Lead
cromwellryan
134
9.3k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
32
5.9k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
46
9.6k
Optimizing for Happiness
mojombo
379
70k
Speed Design
sergeychernyshev
30
990
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
657
60k
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 ビット 反転 移項 β α