|
Boost : |
From: Maarten Kronenburg (M.Kronenburg_at_[hidden])
Date: 2006-05-26 10:39:35
Guillaume,
Your questions are very legitimate.
At some points it is argued that it is better
to store the sign separate from the absolute value.
As the absolute value is non-negative, there is
no choice between ones and twos complement.
I will make a remark in these member functions
about this.
This way the results of these member functions
are indifferent to sign, and do not depend
on machine word size.
The counting starts with bit number 0.
So is_odd now becomes lowest_bit() == 0.
Sub integers exceeding the highest bit are of
course as if the integer is padded with zero bits.
With the current memory sizes, in my opinion
the factor 8 is not purely theoretical.
This way I also keep the migration to 64-bit
out of my design, except of course for the
integer_allocator class.
Regards, Maarten.
"Guillaume Melquiond" <guillaume.melquiond_at_[hidden]> wrote in message
news:1148649293.19309.52.camel_at_saline...
Le vendredi 26 mai 2006 à 14:08 +0200, Maarten Kronenburg a écrit :
> As a response for a request for sub
> integers, in the document I will delete the
> is_even and is_odd member functions,
> and add:
> const integer highest_bit() const;
> const integer lowest_bit() const;
In my opinion, is_odd and is_even have a clearer meaning. When I read
lowest_bit and highest_bit, a lot of questions come to my mind:
Are they implementation-defined? Or are they the lowest and highest bits
in a sign-magnitude representation of integers? Or is it a 2's
complement representation? Or maybe a 1's complement representation? Is
the highest bit of a positive integer always 1? Or will its value depend
on the machine word size and the integer size? Do these functions really
have to return an integer?
> const integer get_sub( const integer &, const integer & ) const;
> By the way here no size_type is used, because
> size_type suffices for the range of bytes,
> but not for the range of bits, which is a factor
> 8 larger.
Same kind of question here: this member extracts a sub-integer with
respect to which representation? For example, what does a sub-integer of
a negative integer look like?
Also I wouldn't worry too much about size_type being too short by a
factor 8 :-). Somebody who really needs to use integers that long will
probably use its own hand-crafted classes in order to be sure a library
will not do any memory allocation to store them.
Sorry if all these questions were already answered in your draft and I
failed to find it.
Best regards,
Guillaume
_______________________________________________
Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk