Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.postscript > #3202
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Carlos <carlos@cvkm.cz> |
| Newsgroups | comp.lang.postscript |
| Subject | Re: Reversing the bits in a byte |
| Date | Sat, 2 Dec 2017 12:46:13 +0100 |
| Organization | A noiseless patient Spider |
| Lines | 23 |
| Message-ID | <20171202124613.29bdcab2@samara.DOMA> (permalink) |
| References | <3034e442-21ab-4c37-aef0-fb1b60a49856@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=US-ASCII |
| Content-Transfer-Encoding | 7bit |
| Injection-Info | reader02.eternal-september.org; posting-host="83aa1c7ced58b0631e3711c2cb4160c6"; logging-data="28030"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18DUV4lckaTez5tGbawnyg7irdAeiI/cnM=" |
| X-Newsreader | Claws Mail 3.15.1-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) |
| Cancel-Lock | sha1:WaK0N+wjd/D/b+30tei/E/wSoXw= |
| Xref | csiph.com comp.lang.postscript:3202 |
Show key headers only | 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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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