Apparently unsigned types really are necessary
Jonathan M Davis
jmdavisProg at gmx.com
Sun Jan 22 01:44:02 PST 2012
On Sunday, January 22, 2012 10:31:17 Marco Leise wrote:
> Am 22.01.2012, 08:23 Uhr, schrieb bcs <bcs at example.com>:
> > Rename them bits{8,16,32,64} and make the current names aliases.
>
> So everyone uses int, and we get messages like: "This program currently
> uses -1404024 bytes of RAM". I have strong feelings against using signed
> types for variables that are ever going to only hold positive numbers,
> especially when it comes to sizes and lengths.
Whereas others have string feelings about using unsigned types for much of
anything which isn't intended for using bitshifts with. Lots of bugs are
caused by the use of unsigned integral values. I know that Don wishes that
size_t were signed and thinks that it's horrible that it isn't. I suspect that
you will find more people who disagree with you than agree with you on this.
Now, whether having bits8, bits16, etc. is a good idea or not, I don't know,
but there are a lot of programmers who don't particularly like using unsigned
types for normal arithmetic, regardless of what values the variable holds.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list