Boost logo

Boost :

Subject: [boost] [xint] Design Question
From: Chad Nelson (chad.thecomfychair_at_[hidden])
Date: 2010-06-16 09:57:29


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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
infinitely long.)

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?
- --
Chad Nelson
Oak Circle Software, Inc.
*
*
*
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkwY2EYACgkQp9x9jeZ9/wSZuACgqIjJ85p0wUrwhCR/tcvY8QUL
bagAniFZU/UGwKfpK7juhuWYxXwMb2Ar
=qvcJ
-----END PGP SIGNATURE-----


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk