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
62
.NETの上でお手製の言語を動かす技術
taiseiue
0
87
AIの力でお手軽Chrome拡張機能作り
taiseiue
0
340
振り向き美人
taiseiue
0
22
(自作の)プログラミング言語ができるまで
taiseiue
1
440
Other Decks in Programming
See All in Programming
kiroとCodexで最高のSpec駆動開発を!!数時間で web3ネイティブなミニゲームを作ってみたよ!
mashharuki
0
130
Cursorハンズオン実践!
eltociear
2
990
株式会社 Sun terras カンパニーデック
sunterras
0
280
Things You Thought You Didn’t Need To Care About That Have a Big Impact On Your Job
hollycummins
0
220
コードとあなたと私の距離 / The Distance Between Code, You, and I
hiro_y
0
130
iOSエンジニア向けの英語学習アプリを作る!
yukawashouhei
0
190
Introducing ReActionView: A new ActionView-Compatible ERB Engine @ Kaigi on Rails 2025, Tokyo, Japan
marcoroth
3
1k
あなたとKaigi on Rails / Kaigi on Rails + You
shimoju
0
130
技術的負債の正体を知って向き合う / Facing Technical Debt
irof
0
160
CSC305 Lecture 04
javiergs
PRO
0
270
CI_CD「健康診断」のススメ。現場でのボトルネック特定から、健康診断を通じた組織的な改善手法
teamlab
PRO
0
210
Software Architecture
hschwentner
6
2.3k
Featured
See All Featured
Building Applications with DynamoDB
mza
96
6.7k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Building an army of robots
kneath
306
46k
Building Flexible Design Systems
yeseniaperezcruz
329
39k
How to train your dragon (web standard)
notwaldorf
96
6.3k
Build The Right Thing And Hit Your Dates
maggiecrowley
37
2.9k
Statistics for Hackers
jakevdp
799
220k
Code Reviewing Like a Champion
maltzj
526
40k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
189
55k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
132
19k
GraphQLとの向き合い方2022年版
quramy
49
14k
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 ビット 反転 移項 β α