• PinkiePieYay2707@pawb.social
    link
    fedilink
    English
    arrow-up
    19
    ·
    4 days ago

    Nope, pull those glasses down. There is no such thing as integer underflow, as the concept of underflowing refers to a lack of precision when attempting to enter a precise value. In other words, this applies to floats and doubles (and similar decimal types).

    Example of how underflow looks like (though I admit it is a very basic example): you can put a number with two decimal places into a variable, but then you attempt to enter a number with three decimal places instead. In this example you will end up with either a rounded or cut-off number, because it would be impossible to enter that last decimal place, thus you lose precision. Hopefully this makes some sense, because in reality floats make little sense with all those mantissas and whatnot (ok they do make sense, but it’s really hard and I don’t like it).

    Overflow refers to going from one end to another, regardless of direction. Try to type “integer underflow” in wikipedia, it should redirect you to overflow instead.

    • queerlilhayseed@piefed.blahaj.zone
      link
      fedilink
      English
      arrow-up
      8
      ·
      4 days ago

      Hold on to those glasses for a second. I searched for “integer underflow” and the first result was the wikipedia article for Integer Overflow which has this passage in the “Definition variations and ambiguity” section:

      The case of an integer operation producing a value less than the smallest representable value is sometimes called integer underflow, though most commonly it is known as a type of overflow.[30] This usage is quite different from floating-point underflow, which refers to a floating-point value that is too close to 0.

      That citation points to this definition on mitre (formatted for clarity):

      CWE-191: Integer Underflow (Wrap or Wraparound): The product subtracts one value from another, such that the result is less than the minimum allowable integer value, which produces a value that is not equal to the correct result.

      Integer underflow refers to a type of overflow (that is, an overflowing of the minimum bound instead of the maximum bound) and it’s a different thing than floating point precision loss. To use the odometer example from Wikipedia, it would be like running the odometer backward until it goes from 000000 to 999999, which is an invalid result since 0 - 1 =/= 999999.

      Given the evidence, I move that the council of pedants keep /u/verdare’s glasses pushed up. I further move that they get bonus pedantry points since they are both technically correct and needlessly specific, since it is also true that “overflow” is correct in this case, which is the most pedantic kind of correct :)