Boost logo

Boost :

From: Dan Nuffer (dnuffer_at_[hidden])
Date: 2000-09-21 12:18:46


>
> > Presumably the interfaces should be either the same or very similar?
>
> At least very similar. A bigint type leaves a few operations
> ambiguous as to implementation. For instance, bit manipulation
> operators may not be intuitive when the bitsize is variable.
> Typically the implementations I've seen assume bits to be 0 beyond
> the size of the actual storage for this. More complex is the shift
> operators. >> will obviously drop a bit the same as it does with
> built in integral types. But what about <<? Does it drop a bit or
> scale the size?
>
> Bill Kempf

I took the approach of scaling the size. Partly because this
functionality is needed by multiplication. Now that I think about it,
this behavior may be surprising, because it is different than a built-in
int, which would drop a bit.
Another thing to think about: What happens when you binary
or(and,xor,etc) together a large positive integer with a small negative
integer? Do you sign extend the smaller number or just fill in zeros
instead? Or do bitwise operations even make sense for variable sized
integers? Why would someone need them?

--Dan


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