News for hackers. Stuff that matters.
Re:Should I Use Signed or Unsigned Ints? (Part 2) by mojuba on Tuesday September 01, 2015 @08:46PM (#10156800)
One of the most annoying problems in C and C++ (and Objective-C/C++). Most of the time we deal with quantities, sizes, distances, coordinates, identifiers. Except for the latter, all others can end up in the negative space even when we think they shouldn't. Having said that, identifiers and enumerated codes should also live in the signed realm as they can get converted to other types, again, in ways we can't always predict (and result in bugs).
Re:Should I Use Signed or Unsigned Ints? (Part 2) by cpeterso on Tuesday September 01, 2015 @11:53PM (#10157339)
I wish C++ had a better way of representing quantities, something like Pascal's or Ada's ranged integer types. I started to write a C++ template class to represent strongly-typed ints. The class grew to 100+ LOC to handle all the expect operator overloads. Then I gave up. :) C++11 gave us strongly-typed enums and the means to specify the enum's underlying size (like enum class Color : unsigned short). Why can't they give us strongly-typed ints with something like int class Fahrenheit?