Boost logo

Boost :

From: Maarten Kronenburg (M.Kronenburg_at_[hidden])
Date: 2006-05-29 09:55:01


In my opinion the unsigned integer with a modulus
is required, which is generalizing the base type
unsigned int (which is modular) to any modulus.
So the unsigned_integer would have a static method
void set_modulus( const integer & ).
The only problem is what an unsigned_integer is
when a modulus is not providid, that is when
the modulus is zero.
Then I propose that as the user did not provide
any modulus, only in this case negating a non-zero
unsigned_integer will be an error.
Also I propose that such an unsigned_integer will be
provided by implementations, and be added
to the specification.

"Maarten Kronenburg" <M.Kronenburg_at_[hidden]> wrote in message
news:e5c7h0$vht$1_at_sea.gmane.org...
> Perhaps we have to specify such an unsigned
> (modular) integer so that implementations can provide it.
> Such an unsigned_integer would then have a
> static method set_modulus( const integer & ).
> Then I should merge the unsigned_integer and
> modular_integer into unsigned_integer in the
> document.
> I will refer to [expr.unary.op] item in any case.
>
> "Sebastian Redl" <sebastian.redl_at_[hidden]> wrote in message
> news:4478BF17.7020404_at_getdesigned.at...
> > Beman Dawes wrote:
> >
> > >That isn't correct, AFAICT. An unsigned does support unary negation.
> > >
> > >5.3/9 says "The operand of the unary - operator shall have arithmetic
or
> > >enumeration type and the result is the negation of its operand.
Integral
> > >promotion is performed on integral or enumeration operands. The
negative
> of
> > >an unsigned quantity is computed by subtracting its value from 2n,
where
> n
> > >is the number of bits in the promoted operand. The type of the result
is
> the
> > >type of the promoted operand."
> > >
> > >
> > The operator exists, but only for the language unsigned integers, which
> > aren't really unsigned integers, but modulo integers, as is obvious from
> > the definition of the negation. The same definition is impossible for a
> > (theoretically) infinite-precision integer, because, lacking a number of
> > bits in the representation (n), there is no 2^n from which can be
> > subtracted.
> >
> > Sebastian Redl
> > _______________________________________________
> > Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
> >
>
>
>
> _______________________________________________
> 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