aardappel / treesheets

TreeSheets : Free Form Data Organizer (see strlen.com/treesheets)
zlib License
2.49k stars 184 forks source link

Member variables for selection position and length are never negative #634

Closed tobiolo closed 2 months ago

tobiolo commented 2 months ago

Use uint8_t. wxDataOutputStream::Write8(wxUint8) and wxDataInputStream::Read8 also uses only unsigned integers.

aardappel commented 2 months ago

Something being never negative is a bad reason for using unsigned in C++. You make code more brittle since there are lots of subtle code patterns where substracting can now wrap (which usually has worse results than being negative). Also mixing signed and unsigned can produce subtle issues. Best is to simply use signed everywhere.

tobiolo commented 2 months ago

Thanks for your explanation! I came to the same conclusion then, but not with the perspective of the wrap in substraction cases. Thanks for having pointed out! Best to learn the basic Computer Science stuff the hard way, a good motivation for the theoretical stuff. Thank you 🙏 for the feedback! Have a nice day over in America!