Whats the difference when your using bitwise operators and logical operators in a conditional statements?
if ((val==1)|(val==2)) printf("%d\n",val);
if ((val==1)||(val==2)) printf("%d\n",val);
Which do you think is better and why is that? Thanks again for the replies ^_^
>>i found this/
someone correct me if I'm wrong: both bitwise and logical operators are the representation of the boolean function with the same names(better read on that first as I suspect the fact that you haven't) the diference is that the bitwise ones operate on bits(it doesn't matter if your data type has 8,16,32 or 64 bits, the operation is applied to every bit of the operands e.g 1|1 =1 10|01 =11, 100|1 = 101 and so on), where as the logical operators operate on logical atoms( the whole atom is considered as a bit, the interpreted values are false for 0 and true for non-zero values)
^ basically right, except that nowhere does Java define any mapping between 0 and 1s vs the boolean values false/true.
Bitwize operators work on each bit of an int value, the logical operators work on individual boolean true/false values, but there's no connection between these two versions.
Ohh, When i asked this question, it was almost midnight in my country :) I think this is the reason why i did not understand the difference. Now I am so regretful for asking this simple question. Thank you all guys.
Hey, so I wanna ask how I need to create a method who will remove word if in that word is 2 same chars. Example: "Potato" in this word there is a 2 "o" chars so this word will need to be removed. "Forum" in this word there is no ...
Help! I want to create a java program that finds the highest even integer among the values entered by the user. Stop asking values when a value less than 1 have been entered. If no even integer is entered, display "No Even Integer"
I am writing a java program that needs to execute shell commands, so I wrote a function that would take the command to execute as a string (ie: "mkdir ~/Folder1") and execute that command with the shell. Here is the function:
Runtime run = Runtime.getRuntime();
Process pr = ...