wewbull

joined 2 years ago
[–] wewbull@feddit.uk 9 points 1 day ago (2 children)

It's a lemming, damn you.

[–] wewbull@feddit.uk 8 points 1 day ago* (last edited 1 day ago) (1 children)

When you're working with the binary representation of numbers.

In your code you had three numbers 25, 10 and 5. If we write those number in binary we get:

  • 25: 0b00011001
  • 10: 0b00001010
  • 5: 0b00000101

(The 0b at the start is just a way of saying "this is binary")

When you do a bitwise-or, it's a bit like adding up but you don't bother with carrying anything. So let's do 25 | 10, starting at the right-hand end going bit by bit (bitwise):

  • 0 | 1 = 1
  • 1 | 0 = 1
  • 0 | 0 = 0
  • 1 | 1 = 1
  • 1 | 0 = 1
  • 0 | 0 = 0 for all the rest

So the result is 0b00011011 which is 27.

So now you're asking "when would I ever need to do such a thing?" and the flippant answer is "you'll know when you need it".

You're looking for more though, I know. Basically computers often put multiple bits of data into bitstreams (long sequences of bits). Think networking and file storage. Constructing these bitstreams is done with bitwise operators like |, &, ^, << and >>. Together they form a different type of maths to what you're used to.

These operators work in a very similar way to how +, -, * and / work. They take two numbers and return a third. If we rewrite your code using operators you're more familiar with...

    if coin == 25 | 10 | 5:  # if coin == 31
        ...
    if coin == 25 + 10 + 5:  # if coin == 40
        ...

...you can see it's obviously wrong because you're doing one comparison with the result of the operation (addition or bitwise-or), not three comparisons.

[–] wewbull@feddit.uk 25 points 1 day ago (1 children)

If you want to avoid giving people rights that are meant to apply to all humans, you are doing something very wrong.

[–] wewbull@feddit.uk 6 points 1 day ago (7 children)

Is 3,000km impressive? It's the distance from London to Athens. I'm sure people have done that many times.

[–] wewbull@feddit.uk 6 points 2 days ago

Are you a duck?

[–] wewbull@feddit.uk 5 points 2 days ago

Can't really go wrong with Sennheiser.

[–] wewbull@feddit.uk 15 points 2 days ago* (last edited 2 days ago)

Probably less addictive.

[–] wewbull@feddit.uk 1 points 2 days ago (1 children)

Of course compressing isn't a good solution for this stuff. The point of the comment was to say how unremarkable the original claim was.

[–] wewbull@feddit.uk 41 points 2 days ago (4 children)

Don't replace social media with something else on your phone.

Put the phone down and walk away.

[–] wewbull@feddit.uk 1 points 2 days ago (3 children)

It all depends on the data entropy. Formats like JSON compress very well anyway. If the data is also very repetitive too then 2000x is very possible.

[–] wewbull@feddit.uk 5 points 2 days ago (1 children)

...but why do the shelves look like they incinerated the bottles in-place?

[–] wewbull@feddit.uk 1 points 3 days ago

That Reeves and Mortimer Look.

view more: ‹ prev next ›