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
すべてはバイナリ
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Satoru Takeuchi
PRO
June 06, 2020
Technology
220
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
すべてはバイナリ
以下動画のテキストです。
https://youtu.be/8qg2b8ZZm_c
Satoru Takeuchi
PRO
June 06, 2020
Transcript
16 slides
すべてはバイナリ Jun 6th, 2020 Satoru Takeuchi Twitter: satoru_takeuchi 1
目次 1. コンピュータにおける情報の表現方法 2. 整数の表現方法 3. 文字の表現方法 4. まとめ 2
目次 1. コンピュータにおける情報の表現方法 2. 整数の表現方法 3. 文字の表現方法 4. まとめ 3
コンピュータシステムのデータといえば… • 人間から見て半端な、不自然な数が多い ◦ データの単位であるバイトは 8bit → 10bitじゃだめなの? ◦ メモリ量16GB、32GBとか
→ なぜ30GBとか40GBじゃだめなの? ◦ 32 bit CPUとか64bit CPUとか → なぜ50bitとか100bitじゃだめなの? • これらの数値は全部2^n • 理由: データは2^n単位で扱うのが自然 4
データの実体 • データは何らかの物理的な素子のon/offのかたまりであらわされる ◦ メモリ(DRAM), SSD: 素子内の電荷 ◦ HDD: 磁性体の磁化の向き
◦ DVD: ディスク表面の溝の深さが閾値以上かどうか • たくさんのデータを表現したければ素子を大量に並べる • 1つが1ビット、ビットが8つ集まると1バイト 5 素子1つ: 表現できる状態は2つ 素子2つ: 表現できる状態は4つ off off off on off on on off on on
データの数値表記 • データは二進表記するのが便利 ◦ ビットが立っているかどうかが一目でわかる 6 素子の状態: 素子の数は3つ → 3bit
10進表記 2進表記 0 000 1 001 2 010 3 011 4 100 5 101 6 110 7 111 off off off off off on off on off off on on on off off on off on on on off on on on
16進表記 • 2進表記は桁数が大きくなるのでデータは16進数で表現することが多い • 便宜上一桁を0~9,a~fで表現する。fに1を足すと桁上がり 7 データの2進表記 16進表記 00000 0
00001 1 .... ... 01111 f 10000 10
すべてはバイナリ • すべてのデータはビットないしバイトの列 ◦ 2進表記されることが多いので一般にバイナリ /バイナリデータと呼ぶ • データの例 ◦ 整数
◦ 文字列 ◦ 画像 ◦ 音声 ◦ 動画 • それぞれ規格が決まっている ◦ ときには自分で決めなければいけないこともある ▪ 例: 独自アプリ内のデータ通信方法 8
目次 1. コンピュータにおける情報の表現方法 2. 整数の表現方法 3. 文字の表現方法 4. まとめ 9
表現方法 • 0以上の整数(符号なし整数)について扱う ◦ 負の数を考えると2の補数が云々とか難しい話が出てくるので省略 • データの2進数表記がそのまま数値に対応するのでスゲエ楽! 10 0以上の整数の値 データの2進表記
10進表記 16進表記 0 00000 0 0 1 00001 1 1 2 00010 2 2 ... ... .... ... 15 01111 15 f 16 10000 16 10
演習 • 使うもの ◦ xxdプログラム(xxdパッケージに入っている ): ファイルの中身を2進表記や16進表記で見る ◦ (自作)numプログラム: 1バイトで表現される符号なし整数値を標準出力に書き込む
• やること ◦ 以下の表に記載されている整数値の 2進、16進データ表現を見る 11 0以上の整数の値 データの2進表記 16進表記 0 00000 0 1 00001 1 2 00010 2 ... ... ... 15 01111 f 16 10000 10
目次 1. コンピュータにおける情報の表現方法 2. 整数の表現方法 3. 文字の表現方法 4. まとめ 12
表現方法 • ASCII Codeという規格について扱う ◦ https://www.ieee.li/computer/ascii.htm ◦ 1バイトで一文字を扱う ◦ 数値、アルファベット
(小文字、大文字)、一部記号を表現可能 • 日本語とか考え出すと終わらないので省略 ◦ キーワード: Unicode, UTF-8, 文字コード, 地獄 13
演習 • 使うもの ◦ xxd • やること ◦ 適当に文字やら文字列をファイルに書いて xxdで覗いてみる
14
目次 1. コンピュータにおける情報の表現方法 2. 整数の表現方法 3. 文字の表現方法 4. まとめ 15
まとめ • データは物理的素子の状態(on/off)によって表現する ◦ 2つの状態をあらわすものがビット、それが 8つ集まるとバイト ◦ 2進表記、16進表記が楽 • すべてのデータはビット列で表現されるバイナリ
• 多くのデータは表現方法が規格化されている 16
More Decks by Satoru Takeuchi
See All by Satoru Takeuchi
Btrfsのsnapshotとランダム書き込み
sat
PRO
0
51
ファイルシステムのデフラグ
sat
PRO
1
58
コピーオンライト型ファイルシステムと ランダム書き込み
sat
PRO
2
130
119-多機能ファイルシステムBtrfs_のコピー.pdf
sat
PRO
1
90
Linuxカーネルの インタフェースは変わりうる?
sat
PRO
1
120
あなたの知らないバージョン命名規則
sat
PRO
3
940
Rook: Intro and Deep Dive with Ceph
sat
PRO
1
87
Machine Check Exception
sat
PRO
2
78
バイナリダンプの模様を読む
sat
PRO
0
120
Other Decks in Technology
See All in Technology
MCPでネットワーク障害調査を自動化する前に直すべき3つのこと
yama3133
1
640
要件定義をAIに委任!Claude Codeプラグインで作るPdM × AgentTeams
puku0x
0
100
cdkdがどんだけ早いか、実際に動かして見てみよう
smt7174
1
130
エンタープライズIAMについて - ID・権限をどう統制するか
oidfj
1
250
未来を描き変化の中で学び直す ヴァンガードから考える、AI時代のチーム開発
lamb_moko
0
120
re:Inventを楽しむために、 1日1つ「これが楽しみ」を決めよう
beli68
0
120
常時稼働エージェントの作り方(Claude公式ブログを資料化)
minorun365
PRO
17
28k
kubellの最新データ分析環境
kubell_hr
2
190
Linuxネットワークスタック進化の軌跡: 過去10年の歩みと最新トレンド
orimanabu
4
770
統制されたID・権限をどう利用するか : DPoP/FAPIによるAPIセキュリティ強化
oidfj
1
230
変更差分を読むために環境を整備しよう
pipepasta
1
480
エンタープライズ事業未経験のデータ屋、 AI時代にN回撃沈する.pdf
ryoskdara_
0
170
Featured
See All Featured
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Marketing to machines
jonoalderson
1
6k
Code Review Best Practice
trishagee
74
20k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
460
Designing Experiences People Love
moore
143
24k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
2
540
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
760
Into the Great Unknown - MozCon
thekraken
41
2.8k
Producing Creativity
orderedlist
PRO
348
41k
Exploring anti-patterns in Rails
aemeredith
4
570
Navigating Team Friction
lara
192
16k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
330