
On Wed, 09 Mar 2011 11:25:57 -0800 "Jeffrey Lee Hellrung, Jr." <jhellrung@ucla.edu> wrote:
The design I see would require all such user-supplied magnitude types to have a reallocation function that the library can call. If that function doesn't provide the memory requested, the user gets only the lower bits of the correct result. The code for handling that is already in the library, for the fixed-length integers.
I'd like to hear more specifics about this idea...if you have more specifics at the moment, that is.
Only the design in my head. XInt would require a few things of the user-specified type: it must have functions for setting and retrieving the sign and the used memory, accessing the memory, and getting the current reserved size of the memory. It must have a function for allocating more memory, which can be a no-op if you don't want the type to get any larger (though it won't guarantee the right answer in that case). It must have a typedef for the digits of the magnitude, and that type must have properties similar to xint::digit_t. Probably a few other things, which I won't know until I actually try writing code to use it.
I think that can be handled by putting the onus of dealing with it onto the person providing the new type.
E.g., by supplying a policy class of fundamental operations...? [...]
However the implementor desires, so long as it provides sign and magnitude in the way that the functions can use.
Perhaps such discussions on the design of a generic interface are best left for after the review. I couldn't help but throw some ideas out there already, though ;)
Yes, there's plenty to do before I even seriously think about that. -- Chad Nelson Oak Circle Software, Inc. * * *