Skip to content
0:00 / 0:00

#two'scomplement#signedintegers#undefinedbehavior

CppCon 2018: JF Bastien “Signed integers are two's complement”

CppCon

189K subscribers • 103 videos on Hallway • Conference channel

YouTube
  • Recommended by 1 person: 1 in engineering communities.
  • Presented by JF Bastien, compiler engineer at Apple
  • Linked in the descriptionCppCon/CppCon2018

Intermediate. Assumes working knowledge.

19K views7 years ago1 recommendation

Programming languagesSystems programmingC++Compilers and interpreters

JF Bastien explains the history and standardization of two's complement representation for signed integers in C++.

CppCon.org — Presentation Slides, PDFs, Source Code and other presenter materials are available at: github.com/CppCon/CppCon2018 — There is One True Representation for signed integers, and that representation is two’s complement. There are, however, rumors of a fantasy world—before C++20—where ones' complement, signed magnitude and "pure binary representations" dwell. That world boasts Extraordinary Values, Padding Bits, and just like our world it hosts swaths of Undefined Behavior. Join me in exploring this magnificent fantasy world, and discover its antics. Together we'll marvel at how the other representations were forever banished from real-world C++, doomed to cast mere shadows onto our reality. — JF Bastien, Compiler engineer Apple JF is a compiler engineer. He leads C++ development at Apple. — Videos Filmed & Edited by Bash Films: BashFilms.com Work at Hudson River Trading (HRT): tinyurl.com/safxfctf --- Videos Filmed & Edited by Bash Films: BashFilms.com

Why it's here

1 person recommends this

What people say. Recommended for understanding why signed integers are defined as two's complement and the removal of historical alternatives.

u/TheKiller36_realin r/C_Programming • Recommends

On “How would you improve C if you could ignore legacy concerns?”

- <your examples> - meta programming - `constexpr` functions - basically all of the standard library - remove `errno` side-effects etc. - make `inline` equivalent to / more like C++ `inline` - define `char` to have 8 bits - signed integers are two's complement - rework of bit-fields - remove strict aliasing rules and allow for easier type-punning - standardize more attributes - vector facilities (e.g. std-lib equivalents to Intel intrinsics) probably more but this came to mind first