bitwise shifts gone?

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

bitwise shifts gone?

Niggemann, Bernd via use-livecode
Hmmm...

I just noticed that the bitwise shift left and right operators have
disappeared from the language. When did this happen? The 'bitwise'
modifier is still in the dictionary, but no indication as to how it
might still be useful.

 From this I assume (yeah, I know...) that the engine is smart enough to
compile a shift instead of a multiply if the multiplier is a multiple
(see what I did there?) of 2. YMMV.

--
  Mark Wieder
  [hidden email]

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: bitwise shifts gone?

Niggemann, Bernd via use-livecode
Mark,

obviously you ask relating to Bob's IPv4 sort problem.

But when optimising (for speed) the connected formula

(1) a + b * 2^8 + c * 2^16 + d * 2^32

using the constants is slightly faster:

(2) a + b * 256 + c * 65536 + d * 16777216

Why is the engine not handling the internal bitshifts easier with (1)?

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: bitwise shifts gone?

Niggemann, Bernd via use-livecode
On 06/30/2018 03:50 AM, hh via use-livecode wrote:
> Mark,
>
> obviously you ask relating to Bob's IPv4 sort problem.

A perceptive observation, as always.

>
> But when optimising (for speed) the connected formula
>
> (1) a + b * 2^8 + c * 2^16 + d * 2^32
>
> using the constants is slightly faster:
>
> (2) a + b * 256 + c * 65536 + d * 16777216

Would bitOr operators increase the speed over additions?

>
> Why is the engine not handling the internal bitshifts easier with (1)?

Indeed. I'm not too upset about the loss of the bitshift operators other
than the lack of backward compatibility, but I'm surprised by their
demise. In terms of minimal use of microprocessor cycles I'd expect that
the fastest would be

a || (b << 8) || (c << 16) || (d << 32)

--
  Mark Wieder
  [hidden email]

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: bitwise shifts gone?

Niggemann, Bernd via use-livecode

> On Jun 30, 2018, at 8:00 AM, Mark Wieder via use-livecode <[hidden email]> wrote:
>
> Indeed. I'm not too upset about the loss of the bitshift operators other than the lack of backward compatibility, but I'm surprised by their demise. In terms of minimal use of microprocessor cycles I'd expect that the fastest would be
>
> a || (b << 8) || (c << 16) || (d << 32)

Yabut - I don’t know if LCScript understands integer numerics. Aren’t numbers always handled as floating point?
.Jerry


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: bitwise shifts gone?

Niggemann, Bernd via use-livecode
On 06/30/2018 10:03 AM, Jerry Jensen via use-livecode wrote:
>
>> On Jun 30, 2018, at 8:00 AM, Mark Wieder via use-livecode <[hidden email]> wrote:
>>
>> Indeed. I'm not too upset about the loss of the bitshift operators other than the lack of backward compatibility, but I'm surprised by their demise. In terms of minimal use of microprocessor cycles I'd expect that the fastest would be
>>
>> a || (b << 8) || (c << 16) || (d << 32)
>
> Yabut - I don’t know if LCScript understands integer numerics. Aren’t numbers always handled as floating point?

The operator formerly known as bitShiftLeft would have to use integers,
at least down at the bytecode level. I think numbers are always strings
unless they're not.

--
  Mark Wieder
  [hidden email]

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: bitwise shifts gone?

Niggemann, Bernd via use-livecode
In reply to this post by Niggemann, Bernd via use-livecode
On Jun 30, 2018, at 8:00 AM, Mark Wieder via use-livecode
<[hidden email]> wrote:
> Indeed. I'm not too upset about the loss of the bitshift operators other than the lack of backward compatibility, but I'm surprised by their demise. In terms of minimal use of microprocessor cycles I'd expect that the fastest would be
>
> a || (b << 8) || (c << 16) || (d << 32)

I just looked back in dictionaries for older version back to 6.7.11 and
there are no shift operators in the dictionary. You have bitAnd, bitOr,
bitXor and botNot, but no shifts operators. Are you sure there were ever
in the language to begin with?


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: bitwise shifts gone?

Niggemann, Bernd via use-livecode
In reply to this post by Niggemann, Bernd via use-livecode

> On Jun 30, 2018, at 10:03 AM, Jerry Jensen via use-livecode <[hidden email]> wrote:
>
>
>> On Jun 30, 2018, at 8:00 AM, Mark Wieder via use-livecode <[hidden email]> wrote:
>>
>> Indeed. I'm not too upset about the loss of the bitshift operators other than the lack of backward compatibility, but I'm surprised by their demise. In terms of minimal use of microprocessor cycles I'd expect that the fastest would be
>>
>> a || (b << 8) || (c << 16) || (d << 32)
>
> Yabut - I don’t know if LCScript understands integer numerics. Aren’t numbers always handled as floating point?

And I read about bitor in the 9.0.0 dictionary: the operands are treated as binary between 0 and a signed 32 bit integer (2^32 - 1) max. So bitor wouldn’t do unless it has grown up into the 64 bit world.

Agreed that bitshift operators would be a desirable operator, not necessarily for this task.
.Jerry



_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: bitwise shifts gone?

Niggemann, Bernd via use-livecode
In reply to this post by Niggemann, Bernd via use-livecode
On 06/30/2018 10:27 AM, Paul Dupuis via use-livecode wrote:

> I just looked back in dictionaries for older version back to 6.7.11 and
> there are no shift operators in the dictionary. You have bitAnd, bitOr,
> bitXor and botNot, but no shifts operators. Are you sure there were ever
> in the language to begin with?

Urk. Good catch. I had the dictionary open to LCB.
nvm.

--
  Mark Wieder
  [hidden email]

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: bitwise shifts gone?

Niggemann, Bernd via use-livecode
In reply to this post by Niggemann, Bernd via use-livecode
On 06/30/2018 10:34 AM, Jerry Jensen via use-livecode wrote:

> And I read about bitor in the 9.0.0 dictionary: the operands are treated as binary between 0 and a signed 32 bit integer (2^32 - 1) max. So bitor wouldn’t do unless it has grown up into the 64 bit world.

<sigh> that's a bit (or 32) disappointing.

--
  Mark Wieder
  [hidden email]

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode