LoginSignup
4
2

More than 5 years have passed since last update.

C++言語仕様は2値以上の"ビット"をサポートするか?

Last updated at Posted at 2012-12-26

Stack OverflowのDoes C++, as an abstraction, support "bits" representing one of more than two values?より。
プログラミング言語C++の言語仕様は、2つ以上の値をとる"ビット"を許容するか?例えば"3状態ビット"であっても成り立つか?というお話。実用性は皆無です

  • C++11標準ではビット(bit)について直接定義している箇所は無いらしい。
  • C++11標準のnoteには言及箇所があるが、それはinformativeであってnormativeじゃないよねと突っ込み。
  • C++11がnormativeに参照するC99標準では下記の定義が行われているとのこと。

1 bit unit of data storage in the execution environment large enough to hold an object that may have one of two values

つまりC99標準でも「2値のうち1個を保持するのに十分なサイズ」としか定義していないようです。これは"ビット"は「少なくとも2値以上の状態をとること」を意味しますが、一方で「必ず2値状態をとること」は意味しないため、やっぱり厳格な答えにはならないねという所のようです。

おしまい。

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2