Re: [AD] shiftoperators (was: improvements on alphablending...) |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
- To: Allegro Developer <conductors@xxxxxxxxxx>
- Subject: Re: [AD] shiftoperators (was: improvements on alphablending...)
- From: Evert Glebbeek <eglebbk@xxxxxxxxxx>
- Date: Fri, 03 Aug 2001 01:13:13 +0200
>> I think the original poster meant whether the new bit (most
>> significant bit in a right shift) would get zeroed (as would happen if
>> the number was positive (in a 2s complement encoding) or set to 1
>> (thus preserving the original number's signedness).
>
>But our numbers are only positive, so this doesn't have any effect.
>(Note that this does not mean that the compiler can optimize a division
>to a shift: even if _we_ know the numbers are positive because of the
>way we designed the algorithm, it does not mean that the compiler can
>figure this out at compile time.) Allegro uses shifts all over, so I
>think if there would be a problem in colblend.c then it would be so at
>many other places as well.
Well, my concern was something like this: how do you know that shifting to
the right corresponds to deviding by 2? I don't know of such machines, but
it would be possible that there are machines that have the low bit at the
*left* of a word, so that the 8 bit number 01000000 would be equal to 2
instead of 64?
Also, couldn't it give incompatibel code between little endian/big endian
encodings?
Anyway, I usually try to avoid shift operators if I want my code to run at
my PC as well as a SUN workstation. Am I over cautious?
Oh, and yes, I know that the compiler will produce division/multiplication
if no shift operators are available in assembly language ;-)
--
Evert Glebbeek, Physics student
Faculty of science, University of Amsterdam
e-mail: eglebbk@xxxxxxxxxx ICQ: 48210348
www: http://www.science.uva.nl/~eglebbk/