Boost logo

Boost :

From: William Kempf (sirwillard_at_[hidden])
Date: 2000-09-21 14:44:55


--- In boost_at_[hidden], Dan Nuffer <dnuffer_at_c...> wrote:
> >
> > > 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?

More than likely you'd sign extend?

I'm not sure that bitwise operations should be included. I'm not
sure why you'd need both bitwise operations and scalable size. A lot
of ambiguous operations would be handled by simply not including
these operations.

Bill Kempf


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