Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.postscript > #3202

Re: Reversing the bits in a byte

From Carlos <carlos@cvkm.cz>
Newsgroups comp.lang.postscript
Subject Re: Reversing the bits in a byte
Date 2017-12-02 12:46 +0100
Organization A noiseless patient Spider
Message-ID <20171202124613.29bdcab2@samara.DOMA> (permalink)
References <3034e442-21ab-4c37-aef0-fb1b60a49856@googlegroups.com>

Show all headers | View raw


[luser droog <luser.droog@gmail.com>, 2017-12-01 21:28]
[...]
> %reverse the bits in a byte
[...]
> Now applying this new idea, which I have also explained at:
> 
>   https://codereview.stackexchange.com/a/181823/5912
> 
> I get this, which appears much simpler:
> 
> /reverse8 {
>     dup 4 bitshift exch -4 bitshift or
>     dup 16#33 and 2 bitshift exch 16#cc and -2 bitshift or
>     dup 16#55 and 1 bitshift exch 16#aa and -1 bitshift or
> } def
> 
> Exchange the two nibbles, then exchange chomps (?) in each nibble,
> then exchange the bits in each chomp. Is there any better way?

Another possibility is to use a lookup array. (I don't know which one is faster
or better.)
-- 

Back to comp.lang.postscript | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Reversing the bits in a byte luser droog <luser.droog@gmail.com> - 2017-12-01 21:28 -0800
  Re: Reversing the bits in a byte Carlos <carlos@cvkm.cz> - 2017-12-02 12:46 +0100
    Re: Reversing the bits in a byte jdaw1 <jdawiseman@gmail.com> - 2017-12-03 11:58 -0800
      Re: Reversing the bits in a byte luser droog <luser.droog@gmail.com> - 2017-12-04 08:54 -0800
  Re: Reversing the bits in a byte nemo2e4@googlemail.com - 2017-12-05 09:43 -0800
    Re: Reversing the bits in a byte nemo20000 <nemo2e4@googlemail.com> - 2017-12-05 09:58 -0800
      Re: Reversing the bits in a byte luser droog <luser.droog@gmail.com> - 2017-12-05 14:31 -0800
    Re: Reversing the bits in a byte luser droog <luser.droog@gmail.com> - 2017-12-05 15:11 -0800

csiph-web