On Thu, 2011-03-03 at 10:32 -0500, Kohei Yoshida wrote:
One thing to note when reading LibO's code (and also OOo's) is that, a lot of code that are written by the Oracle folks avoid using unsigned integers in favor of signed ones even though unsigned ones would make more sense logically. This is the case especially in newer code, such as chart2 and oox. I have no explanation for this other than to say that this practice was probably largely inspired by Java, which doesn't have unsigned integer types.
Well, there is the following quote from Stroustrup: "The unsigned integer types are ideal for uses that treat storage as a bit array. Using an unsigned instead of an int to gain one more bit to represent positive integers is almost never a good idea. Attempts to ensure that some values are positive by declaring variables unsigned will typically be defeated by the implicit conversion rules." The implicit conversions are implementation dependent when the value is outside the allowed range for the type you're converting to. For some compilers that means a bitwise conversion. I've read C++ books that recommend avoiding unsigned for precisely that reason. That said, I would favour using unsigned's because it makes your intent clearer. But you do need to be very careful about mixing types. Nigel
Attachment:
signature.asc
Description: This is a digitally signed message part