Subject: [boost] [xint] Design Question
From: Chad Nelson (chad.thecomfychair_at_[hidden])
Date: 2010-06-16 09:57:29
-----BEGIN PGP SIGNED MESSAGE-----
I'm adding an "unsigned" option to the XInt library, so that
fixed-length integers act exactly like their built-in counterparts. That
in itself is not a problem, since unsigned fixed-length integers have a
well-known and standard behavior.
The problem is: what should the library do if the user asks for an
unsigned *non*-fixed-length integer?
The options I've come up with so far, in order of my personal preference:
A: Make the unsigned option part of the fixed-length option, so it
*can't* be specified separately. (The most elegant solution, but perhaps
not the most useful.)
B: Refuse to compile (or if I can't find a way to do that, instantiate)
it, on the grounds that the combination can't logically be supported.
C: Throw an exception if any calculation results in a negative number.
(Not very useful, but logical because under the built-in types' unsigned
rules, a negative number in an unlimited-length library would be
D: Force any negative numbers to a different value, such as zero or
maybe their positive counterparts. (I can't think of any use for this, I
just put it here for completeness.)
Can anyone think of a potential reason for options C or D? Or a reason
to prefer option B? Or maybe come up with a different idea entirely?
Oak Circle Software, Inc.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
-----END PGP SIGNATURE-----