To: J3 J3/18-132 From: Robert Corbett Subject: Use cases for unsigned integers Date: 2018-February-14 Reference: 18-122r1 Unsigned integers scored 4.48 on the user survey (WG5 N2147). The reasons users gave for wanting unsigned integers include: (1) improved interoperability with languages that support unsigned integers, C and C++ being the most important, (2) support for system routines that take unsigned arguments or return unsigned results, (3) support for files that include unsigned data (picture files and telemetry data were cited), (4) improved support for manipulation of word-size and multi-word bit data, (5) support for subscript values larger than 2 billion. The vote in the data subgoup was 1-1-3 (for, against, and meh). Proposal -------- The following proposal is based on the Sun/Oracle implementation of the UNSIGNED data type. Add a new data type UNSIGNED. Add a conversion routine named UNSIGNED. Allow the usual arithmetic operations on UNSIGNED data entities. Do not allow mixing signed and unsigned data entities in arithmetic operations. Users must supply explicit conversions if they want to support arithmetic on signed and unsigned values. Comparisons of signed and unsigned values are allowed. The comparisons shall be of the unaltered values. For example, all unsigned values shall be greater than -1. The format edit descriptors I, B, O, and Z shall be extended to support unsigned values. The reason this proposal does not allow mixed signed and unsigned arithmetic is that mixed signed and unsigned arithmetic in other languages has caused a great deal of trouble.