3 ms·
So your gold value was signed? Does WoW allow for debt by tracking negative values, or was it just an oversight?
by reificator 7y ago
So your gold value was signed? Does WoW allow for debt by tracking negative values, or was it just an oversight?
- saalweachter 7y agoSome people just really, really dislike unsigned ints.
- Gibbon1 7y agoI've run into programmers that think something terrible is going to happen if you use an unsigned int for anything.
- perl4ever 7y agoIs there a popular language these days that throws an exception whenever an unsigned int overflows?
- vertex-four 7y agoRust in debug mode or with a compiler option will panic if a number overflows.
- perl4ever 7y agoHuh. That doesn't sound like something people use in production code. Maybe a hardware feature is needed? I mean, it's normal with floating point to handle overflow in a more sensible way, isn't it...
- poilcn 7y agoThere are safe operation extensions like "save add", "save mul" for numbers in Rust which would detect overflows, but you'd have a drawback as it won't return just the number (of type u64, for example), it would return result<u64> and you'd be forced to handle it.
- vertex-four 7y agoThere's also functions which people do use to specify specific behaviour no matter the release mode, where handling overflows properly is particularly important - e.g. cryptography-related code.
- Gibbon1 7y agoI think you can specify 'checked' in C# which will result in an exception on overflow.
- xxs 7y agoSigned numbers are preferred. Imaging you try to buy something checking if the remaining balance would be greater than zero is pretty much guaranteed, resulting in 4+ billion instead. Signed number (just 64bit) is the correct number type for such operations.
- reificator 7y agoPushing it off to the negatives does not solve the issue of overflow.
- deleted 7y ago[deleted]
- xxs 7y ago> Pushing it off to the negatives does not solve the issue of overflow. it allows for comparison with errors. Working with unsigned numbers is error prone... and I started with 6502 that didn't have signed numbers. The idea is preventing the overflow by being able to check for negatives easily. Having negative gold is likely better than leaving someone with 4billons of. For instance stuff like "max(0, balance)" just doesn't work with unsigned ones.
- dTal 7y agoIf the domain is known to be positive, you can use the sign bit as an overflow flag.