Good day!

Explain, please, what does it mean that in the computer the addition operation is not additive?

  • one
    but where does this assumption come from? - Grundy
  • Well, when working with floating arithmetic, this is true. The sum of two numbers may not be equal to their sum :) - Zealint
  • one
    And what does the word "additive" mean in your case? I know only the properties of commutativity, associativity, the presence of a neutral and inverse element. - VladD

1 answer 1

I suspect that such a formulation is not entirely correct, because it is not clear what “in computer” means and what “addition operation” means. But I will answer, as I understood.

Whatever the computer, its memory is limited. If we are talking about numbers in the registers of the processor, then there is always a maximum number, and if we add one to it, we get the minimum number, and not what we expected. Let's say we have 8 bits with a sign. The maximum number will be 0x7F = 127 , we add one, we get 0x7F+1 = 0x80 = -128 . The additivity property is violated.

Further, in floating arithmetic is even worse. The simplest example: adding the large and small numbers together, we get not their sum, but again we get a large number. Let's say 1e30+1e-30=1e30 .

The same can be said about long arithmetic. Sooner or later the memory will end - and the attempt to add two numbers will fail ... but there is already a philosophical question, to consider this failure as an addiction violation or not.

  • What does this reasoning have to do with additivity? You have considered a strictly reverse process. - Akina