|
|
Subscribe / Log in / New account

Better handling of integer wraparound in the kernel

Better handling of integer wraparound in the kernel

Posted Feb 2, 2024 18:10 UTC (Fri) by anton (subscriber, #25547)
Parent article: Better handling of integer wraparound in the kernel

This article uses an unfortunate mixture of Cook's unfortunate terminology and something else (maybe something like the terminology below). Here's an attempt at something better:

There are the following overflow conditions:

  • signed overflow (called "overflow" by Cook)
  • unsigned overflow (called "wraparound" by Cook)

There are the following common behaviours on an overflow:

  • wraparound (the result is the number in the target type that is congruent with the mathematical result modulo 2^b)
  • trapping
  • saturating (used for DSP applications)
  • undefined (the compiler does whatever it likes)
With this terminology, the usage of "wraparound" for signed integers or pointers makes more sense than with Cook's terminology as presented in the article.


to post comments


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds