Boost logo

Boost Users :

From: Pfligersdorffer, Christian (Christian.Pfligersdorffer_at_[hidden])
Date: 2008-08-28 07:29:47


boost-users-bounces_at_[hidden] on Tuesday, August 26, 2008 2:45 PM:

> Christian,
>
>> I like your style of critics. Always put a reference to your opinion
>> so it gets more weight. However I do not agree with everything you
>> write.
>
> We don't have to :) But it's good to see the point of other
> people as well :)
>
>> Sure! I'm curious how you changed my code, send it right over please!
>> :) Especially the right-shifting issue caught my interest! Do you
>> have examples where right shifting does not repeat the sign bit? Let
>> me see how you solved it.
>
> please see the sources attached.
>
> as for the right-shifting, I only tried it on intel-based
> CPUs, so of course here it always works the same. but the C++
> is quite clear:
> right-shifting signed values is implementation dependent,
> regarding the fill bit on the left, so one shouldn't count on it :)

Akos,

I see, you use make_signed and make_unsigned - didn't know those small
gems :) Thanks for pointing that out. The workarounds in the oarchive
are a bit clumsy but hey, if they root out all of the warnings with
little effort.

temp = negative ? (typename boost::make_unsigned<T>::type)
                -((typename boost::make_signed<T>::type)t)
                : t;

Now *that's* a nut :) Quite tricky! But I understand now that both casts
are neccessary. (After trying to remove the second one and rethinking ;)

Regards,

-- 
Christian Pfligersdorffer
Software Engineering
http://www.eos.info

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net