C++ only recently (C++20 or 23) decided to declare that signed integers had to be twos-complemente.
It’s a good example of something produced by some very smart people with deep theoretical knowledge and deep experience in both things that had worked and even more things that had seemed like a good idea at the time but had turned out to be problematic in practice.
It’s a fascinating standard. The process was like the IETF’s but deeper, which is rarely possible.
(I realize the word “deep” was used a lot in this comment, but it seems appropriate)
Z_4
0 1 2 3 4 5 6 7 8 9
0 1 2 3 0 1 2 3 0 1
0 1 -2 -1 0 1 -2 -1 0 18 + -2 = 6 as you would expect.
So a subtraction is basically the addition of a negative number and you don't need any extra hardware to keep track of that.
Floating point is just the integers wearing a funny hat. Fixed point is a different funny hat. The rationals are two integers in a trenchcoat.
[0] https://blog.acolyer.org/2020/10/02/toward-an-api-for-the-re...