#Operator

31 messages ยท Page 1 of 1 (latest)

slate abyss
#

Hello everyone ,
I have the question that when ,why we need for bitwize operator how much we should know about them

queen surgeBOT
#

โŒ› This post has been reserved for your question.

Hey @slate abyss! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

cyan drift
#

and sometimes also things like checksums

#

sometimes for parsing binary files or similar

#

or if you have some sort of (small) bitmap in general or similar

queen surgeBOT
#

๐Ÿ’ค Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping.
Warning: abusing this will result in moderative actions taken against you.

slate abyss
#

but the question now is t that how much i worked and invest time in them or just skipped them

queen surgeBOT
#

๐Ÿ’ค Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping.
Warning: abusing this will result in moderative actions taken against you.

stark swan
#

One thing I like to use in Java since there is no negative indexing to get the n-th last element, is to write list.get(list.size() + ~n) which will do exactly that.

cyan drift
cyan drift
#

code should be readable and doing it with + ~n adds cognitive overhead (people have to think about it to check for correctness)

stark swan
#

I don't use it in production code. Only for Codewars.

stark swan
cyan drift
stark swan
#

But I hate garbage.

cyan drift
#

and if it is hot, C2/Graal/Falcon(?) might

  • inline the reversed() and get() methods
  • remove the allocation/move it to the stack
  • extract the calculation
  • do it directly in the generated code

Not trusting the JVMto optimize it is not a valid argument unless (all of the following must be true for it to be a valid argument)

  • Profiling shows that code is important for performance
  • Bemchmarks have been made and they show it is a significant improvement
#

What makes you think it can optimize list.get(list.size() + ~n) better? Do you have evidence for it?

#

Also, if it's relevant for performance, are you using List, ArrayList or the array directly as the static type?

stark swan
#

Right, virtual method lookups are already bad. Field accesses to get the size. Ultra bad. I only trust bitarithmetics because that's what CPUs are made for.

cyan drift
queen surgeBOT
#

๐Ÿ’ค Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping.
Warning: abusing this will result in moderative actions taken against you.

queen surgeBOT
#

๐Ÿ’ค Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping.
Warning: abusing this will result in moderative actions taken against you.

queen surgeBOT
#

๐Ÿ’ค Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping.
Warning: abusing this will result in moderative actions taken against you.

tribal kayak
queen surgeBOT
#

๐Ÿ’ค Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping.
Warning: abusing this will result in moderative actions taken against you.