~/talk

To Int or to Uint, This is the Question

Talkat CppCon 2024 · on Thursday, 2024-09-19· at 15:15· Adams A, 6700 North Gaylord Rockies Boulevard· [rust]
links:none on file
slides:none on file

Choosing signed vs unsigned changes generated code and runtime: dividing (a+b)/2 yields a different sequence of instructions because signed arithmetic extracts the sign bit and uses arithmetic shifts while unsigned uses logical shifts; summing an arithmetic series compiles to a closed-form for signed but stays a loop for unsigned and thus one version shows 40× faster behavior; the reason is compilers can exploit or must guard against undefined behavior; practical fixes include overflow sanitizers and build flags plus helpers like size_t/ssize_t and make_signed/make_unsigned on x86.

AI-written summary · about

  1. 0:00Introduction
  2. 2:11Int and uint matter in C++
  3. 6:06Signed vs unsigned performance
  4. 15:25How integers are stored
  5. 24:20Pitfalls of mixing types
  6. 33:45Arithmetic series performance
  7. 37:58Undefined behavior and optimizations
  8. 41:55Compiler improvements and flags
  9. 44:47C++11 helpers for types
  10. 46:39Safe comparison functions
  11. 48:05Best practices for type safety
  12. 50:34Summary
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.