Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #9234
| From | "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> |
|---|---|
| Newsgroups | comp.programming |
| Subject | Re: Simpler way to dp binary logical operation using arithmetic? |
| Date | 2018-09-10 22:00 +0200 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <pn6ig9$1kus$1@gioia.aioe.org> (permalink) |
| References | <bx7o6lmzra8t.mz0g7tl4wryj.dlg@40tude.net> <pn66bt$uhj$1@gioia.aioe.org> <tsnbp9qh2k01$.4skcz5j2hgya.dlg@40tude.net> |
On 2018-09-10 21:26, JJ wrote:
> On Mon, 10 Sep 2018 18:32:58 +0200, Dmitry A. Kazakov wrote:
>> P.P.P.S. What about a language that has modulo 2**n numbers AKA binary
>> unsigned numbers. Bitwise operations are defined on them.
>
> I'm not sure what you meant, sorry. The only supported modulo operation is
> the `%` operator.
Modular arithmetic is like this:
1 + 0 = 1 (mod 3)
1 + 1 = 2 (mod 3)
1 + 2 = 0 (mod 3)
1 + 3 = 1 (mod 3)
1 + 4 = 2 (mod 3)
1 + 5 = 0 (mod 3)
etc.
See
https://en.wikipedia.org/wiki/Modular_arithmetic
Bitwise operations are mathematically defined only on power of 2 modulo.
This kind of arithmetic has nothing to do with integer arithmetic except
for sharing numerals, names of operations, some properties of
corresponding operations.
Decent languages have different numeric types for modular integers and
"normal" integers.
> The application doesn't support any bitwise operation at all. It's pretty
> limited, really. It doesn't support bit shifting operators.
Arithmetic shift by n in modular arithmetic of modulo of power of 2 is
equivalent to multiplication by 2**n (in both arithmetics), provided you
can suppress integer overflows.
> It doesn't even
> support custom function. i.e. it's not possible to create my own function.
Why do you bother with that then? (:-)) Life is too short... (:-()
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Simpler way to dp binary logical operation using arithmetic? JJ <jj4public@vfemail.net> - 2018-09-10 22:56 +0700
Re: Simpler way to dp binary logical operation using arithmetic? Julio Di Egidio <julio@diegidio.name> - 2018-09-10 09:30 -0700
Re: Simpler way to dp binary logical operation using arithmetic? JJ <jj4public@vfemail.net> - 2018-09-11 02:13 +0700
Re: Simpler way to dp binary logical operation using arithmetic? Julio Di Egidio <julio@diegidio.name> - 2018-09-10 14:21 -0700
Re: Simpler way to dp binary logical operation using arithmetic? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2018-09-10 18:32 +0200
Re: Simpler way to dp binary logical operation using arithmetic? JJ <jj4public@vfemail.net> - 2018-09-11 02:26 +0700
Re: Simpler way to dp binary logical operation using arithmetic? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2018-09-10 22:00 +0200
Re: Simpler way to dp binary logical operation using arithmetic? JJ <jj4public@vfemail.net> - 2018-09-11 03:22 +0700
Re: Simpler way to dp binary logical operation using arithmetic? David Brown <david.brown@hesbynett.no> - 2018-09-10 18:50 +0200
Re: Simpler way to dp binary logical operation using arithmetic? JJ <jj4public@vfemail.net> - 2018-09-11 03:02 +0700
Re: Simpler way to dp binary logical operation using arithmetic? nobody@example.org (Scott) - 2018-09-11 15:24 +0000
Re: Simpler way to dp binary logical operation using arithmetic? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2018-09-10 18:59 +0100
Re: Simpler way to dp binary logical operation using arithmetic? JJ <jj4public@vfemail.net> - 2018-09-11 03:08 +0700
csiph-web