For faster navigation, this Iframe is preloading the Wikiwand page for 1の補数.

1の補数

この記事は検証可能参考文献や出典が全く示されていないか、不十分です。 出典を追加して記事の信頼性向上にご協力ください。(このテンプレートの使い方)出典検索?"1の補数" – ニュース · 書籍 · スカラー · CiNii · J-STAGE · NDL · dlib.jp · ジャパンサーチ · TWL (2023年3月)

1の補数いちのほすう: ones' complement)は、2位取り記数法の基数とした場合の減基数の補数である[1][2][3][4][5][6]。すなわち、整数 x との2冪乗 2n から 1 を引いた数に等しい数 xc = (2n − 1) − x のことをいう(例:24 − 1 = 15 について、4 に対する1の補数は 11)。

x とその1の補数 xc二進法で表せば、1の補数 xcx との和が n 桁の二進数として表せる最大の数となる数といえる(例:24 − 1 = 11112 について[注 1]410 = 01002 の1の補数は 1110 = 10112)。

二進法において、ある数の1の補数を反数と見なせば、決まった桁数の二進数をそれぞれ非負の数と負の数に対応づけられる(#負の数の表現)。

1の補数表現はコンピュータの分野において、固定長の符号付きの整数型などの表現として利用されることがある。

負の数の表現

[編集]

1の補数を用いて二進数整数に対応づけられる。1の補数の定義より、n 桁の二進数 x とその補数 xc は以下の関係を満たす:

右辺の 2n − 1倍数0 と同一視すれば、上記の関係は以下のように解釈できる:

これは x の補数 xcx反数 x と見なすことを意味する。

1の補数表現

[編集]

#負の数の表現節の方法で反数および減法定義されているとする。更に 0 から 2n−1 − 1 までの非負整数をそのまま通常の位取り記数法における二進表示、

に対応づければ、これらの数の補数として整数に対する1の補数表現が得られる。

具体例として、n = 4 桁の二進数における対応表を以下に示す:

24 についての1の補数表現における、二進数と対応する整数の一覧
対応する整数 二進数 対応する整数 二進数
0 00002 0 11112
1 00012 −1 11102
2 00102 −2 11012
3 00112 −3 11002
4 01002 −4 10112
5 01012 −5 10102
6 01102 −6 10012
7 01112 −7 10002

結局、n 桁の二進数の k + 1 桁目の値を bk ∈ {0, 1} とすれば、1の補数表現は以下のように表せる:

1の補数表現における演算

[編集]

1の補数で表される数は、対応する二進数表示の最上位の値 bn−10 なら負でない値を取り、1 なら正でない値を取る。

1の補数表現において、二進数をビット列とみなせば、符号の反転はビット列 xビットを反転[注 2]することによって行える。x とそれをビット反転させた fx は常に以下を満たす:

上記より、x の1の補数は xc = fx と表せる。従って減法は、

と書き換えられる。ビット反転が反数に対応することから、0000...002111...112 の2つの表現方法を持つ。

脚注

[編集]

注釈

[編集]
  1. ^ 下付きの添字は位取り記数法の基数を表す。
  2. ^ ここでビット反転とは各ビットに対する否定演算を指す。すなわち入力が 0 なら 1 を出力し、入力が 1 なら 0 を出力する。

出典

[編集]
  1. ^ JIS X 0005:2002 2002, 05.08.07 1の補数.
  2. ^ ISO/IEC 2382:2015 2015, 2. Terms and definition. 2121103. ones complement.
  3. ^ JIS X 0005:2002 2002, 05.08.02 基数の補数.
  4. ^ ISO/IEC 2382:2015 2015, 2. Terms and definition. 2121098. radix complement.
  5. ^ JIS X 0005:2002 2002, 05.08.01 補数.
  6. ^ ISO/IEC 2382:2015 2015, 2. Terms and definition. 2121097. complement.

参考文献

[編集]
  • 日本規格協会、情報処理学会 編『JIS X 0005:2002 情報処理用語(データの表現)』日本規格協会、2002年8月31日。 
  • ISO; IEC, eds (2015-05). ISO/IEC 2382:2015 Information technology — Vocabulary. ISO/IEC 

関連項目

[編集]
{{bottomLinkPreText}} {{bottomLinkText}}
1の補数
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?