|
|
|
|
|
by adrian_b
53 days ago
|
|
You are perfectly right, but neither C nor C++ nor many more recent languages derived from them have non-negative integers. The so-called "unsigned" integers of C are integer residues, where each value can be interpreted either as both positive and negative or as neither positive nor negative. In any case no "unsigned" value can be said to be non-negative. You have to go back to languages not contaminated by C, like Ada, to find true non-negative integers among the primitive data types. In C++, it is possible to define a non-negative integer type, which can have good performance if you implement its operations in assembly language. However I am not aware of an open-source library including such a type. |
|