#Bit-Operation
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
realy ?
0xaa is 170
so i shift 2 170 times to the right ?
no, you shift 0xaa to the right twice
the left side of <</>> gets shifted by the amount specified on the right side
left << right
okay i will try it again
32
is the correct answer
yey
what would i do without you two
😂
wow so you are young ?
guys
i did && instead of XOR lol
you know you can just run the code right ?
its a test, i must do it on paper
Snippets
Snippet 30, VALID
(0x99<<2)^(0xaa>>2)```
jshell> `590`
## System out
[Nothing]
it's a test ?
thats kinda spoonfeeding
if it is a test we can't help you any longer
you are not supposed to run the code, instead the task is to understand these
well we kinda can
just not spoonfeeding
test in form of a "Quizz" to check the current knowledge.
Its unrated.
no, that's a test, he is cheating
its not?
yes online test.
similar tasks will probably be in the exam
seems like they are learning for it
im converting the hex numbers to decimal
and then into binary
on paper
and manually solving the expression on paper
but im not sure why it says
char a ?
one char has 1 byte
and 14 has 4 bit
14 would also be the solution for int a ?
2
no
Snippets
Snippet 23, VALID
(int)Character.MAX_VALUE```
jshell> `65535`
## System out
[Nothing]
you know that they are constants for this right ?
↑
are there definition differences ? because for C it says char has one byte
...
also
isn't char size unspecified in c ?
actually it seems to be specified as one byte
one byte
one of the few primitives that has a fixed size
compared to c where size may be random
in java, all primitives are totally defined
all primitives except boolean and char are signed
byte is one byte
short and char are two bytes
int and float are four bytes
long and double are height bytes
and note that those sizes are what you can put inside, their actual size in the computer is undefined
@weak crypt
@weak crypt also, do you know why java char is two bytes ?
not sure because ascii only needs 7 bits to display all characters
that means 8 bit sounds better
maybe to display additional characters ?
japanes letters ? 😄
and well, yes it's enough to display most english characters
but it can't display characters from any other language
like é in french
or whatever other language have
...and then there are language like japanese that have thousands of unique characters
and then you also have symbols
like math symbols
or country symbols
and then you have emojis
which yes are characters
so in order to display all characters in utf8, you need 4 bytes
and while java knew that they needed more than one byte to make it work
I don't think they predicted that it would actually take 4 bytes 
so anyway
c's char is bad
java's char is better but still meh
because the correct answer was 4
-_-
ah and just so you know
characters that are often used but maybe not in english are usually on two bytes
and weird characters like emojis are on four bytes
@weak crypt
I'm doing a master
coool
do logical operators work on integers ?
i think they dont
ah k
0 interpreted as false
anything else as true
don't ? xD
unless you are talking about c
but you marked this channel as java
looks like c to me
so I assume you are talking about java
ahh sry
minus the logical operators on ints, that's valid java
well
i think i need to switch channels for c specific questions
are c questions also good in this channel ?
im doing a bit
c
java tasks are done
for now
create a new thread so it's not confusing