All pastes #468334 Raw Edit

Mine

public text v1 · immutable
·published 2007-05-03 01:23 UTC
rendered paste body
<aca20031> http://pastebin.ca/468287
<aca20031> In this, whats the difference between 0xFF & b, and just b
* DJackScO (xenophobe@secure-team.admin.by.god-l1ke.de) has joined #java
* DJackScO (xenophobe@secure-team.admin.by.god-l1ke.de) has left #java
* dxus (nC_dxus@C22|dxus.users.quakenet.org) has joined #java
* tSh|Kietz is now known as KIETZ
<IRBMe> aca20031, "0xFF & b" instead of just "b" seems redundant
<aca20031> i figured it out, the byte can be signed (-1 to -128)
<IRBMe> "0xFF & b" simply masks off the lower 8 bits of b... but b is a byte and thus only is 8 bits in size so it has no affect
<aca20031> unless b is -113
<aca20031> lol.
* distepPerr (~kwkmq@bbnwebdproxy4.europe.hp.net) has joined #java
<aca20031> $and(-113,255) [Eval ->] 143
<IRBMe> signedness has nothing to do with it
<aca20031> well change 0xFF & b to b and see what you get.
<aca20031> And then tell me if there's any other thing you can think of besides signed bytes that would make the mdifferent
<IRBMe> -113 is 10001111. What's 10001111 & 11111111... just the same: 10001111
<IRBMe> (those are binary by the way)
<aca20031> System.out.println(-113 & 0xFF);
* distepPerr (~kwkmq@bbnwebdproxy4.europe.hp.net) has left #java
<aca20031> 143
* megabozz (~megabozz@c-71-195-158-164.hsd1.ma.comcast.net) Quit (Signed off)
<IRBMe> now try; byte b = -113: System.out.println(b & 0xFF);
<aca20031> 143
<aca20031> ;)
<IRBMe> There is no println function that takes a byte
<IRBMe> there's one that takes an int and one that takes a char
<aca20031> ...
<aca20031> int > byte
<aca20031> its a promotion
<aca20031> so int is a valid pass
* PagisoRhaeg (chief@84-246-89-170.rev.sth.ownit.se) has joined #java
* PagisoRhaeg (chief@84-246-89-170.rev.sth.ownit.se) has left #java
* Ranek` is now known as Ranek
<IRBMe> Apparantly the VM only manages 32 bit numbers, and so byte variables aren't really 8 bit numbers, they are masked ints.
* Ranek` (~Ranek@Ranek.users.quakenet.org) has joined #java
* sChBettMic (jopsuli@c-d688e253.04-404-7570701.cust.bredbandsbolaget.se) has joined #java
* Ranek (~Ranek@Ranek.users.quakenet.org) Quit (Ping timeout)
* sChBettMic (jopsuli@c-d688e253.04-404-7570701.cust.bredbandsbolaget.se) has left #java
<aca20031>  simple enough that when 10001111 isn't seen as a byte anymore (integer) it's no longer negative
<aca20031> the first bit is put into play, 143
<IRBMe> By the way, 143 isn't a valid byte value in Java. Bytes have a range of -128..127, so the code masks off the actual byte value and uses it as an integer, and automatically casting that to an integer converts it to an unsigned value
<aca20031> obviously
<aca20031> thats the point of removing the sign and passing it as an integer
<IRBMe> So the masking has nothing to do with the sign
<aca20031> the question was why does it make a difference
<aca20031> the answer is signed numbers are no longer their original value :P
<IRBMe> No, there is no "sign" removed. Java uses 2s complement. It's because the Java VM, as I explained already, uses 32-bit bytes, not real bytes
<aca20031> im not being literal
<aca20031> that the sign is just bumped off
<aca20031> im saying any signed number becomes a positive integer after the comparison
<aca20031> -127, 1000001 -> 129
<IRBMe> what comparison?
<aca20031> the bitwise comparison.
<IRBMe> what's a bitwise comparison?
<aca20031> ...
<aca20031> the &
<aca20031> comparing against 11111111 in bit terms
<IRBMe> that's not a comparison operator, == is a comparison operator
<aca20031> its still called a bitwise comparisong :x
<IRBMe> no it's not
<aca20031> The AND operator (&) defines a bit-wise comparison between two variables according to the truth table shown in Table 3.4. ...
<IRBMe> yes, in the truth table each bit is compared to produce the resulting bit
<aca20031> anyway I'm not interested in term legistic
<aca20031> In fact, I get it now so none of this really matters :P My question was merely whats the difference in value
<IRBMe> the operator, however, is not a comparison - it is an operator whose result relies ON  a comparison of each bit
<aca20031> i dont give two poots what its called o.o
<IRBMe> well you should
<aca20031> only what it does and what its result is :)
<IRBMe> in order to communicate effectively with other human beings, it generally helps if you know what things are called and not just what they do ;)
<aca20031> Well good thing i no longer need to communicate on this subject, and no longer care whether people would prefer they be called 'bitwise operators' instead of 'bitwise comparison'
<IRBMe> it's not a matter of preference, it is a matter of correctness
* [Wc]BenKj (~nix@a91-152-145-122.elisa-laajakaista.fi) has joined #java
<aca20031> Personalized Results 1 - 10 of about 971,000 for bitwise operation. (0.26 seconds)  Personalized Results 1 - 10 of about 632,000 for bitwise comparison. (0.31 seconds) 
<aca20031> You can forgive me :)
<aca20031> /help &;        &        bitwise comparison
* [Wc]BenKj (~nix@a91-152-145-122.elisa-laajakaista.fi) has left #java
* DF|Laptop (Dataforce@home.dataforce.org.uk) has joined #java
<IRBMe> Yes, that's what it *does*
<IRBMe> That is not what it's *called*
<aca20031> then "the bitwise comparison" wasnt an invalid sentence, because it is comparing the bits...wisely :)
<IRBMe> The & operator DOES a bitwise comparison
<IRBMe> it is not itself a comparator. == is a comparator
<aca20031> and the == operator DOES a comparison too.
<aca20031> they both DO comparisons.
<aca20031> lol.
* Ranek` is now known as Ranek
<IRBMe> yes they do
<IRBMe> and they are both operators, not comparisons
<IRBMe> == is the comparison OPERATOR
<IRBMe> & is the bitwise and OPERATOR
<aca20031> I said "after the comparison"
<aca20031> if they do a comparison
<aca20031> then after the action, the comparison, is a valid sentence
<IRBMe> they DO comparison (in the case of the bitwise &, a bitwise comparison)
<aca20031> if I add 1+1 and say "after the addition" its valid
<IRBMe> and if you did "1 == 1" and says "after the comparison", it would be valid
<aca20031> we just agreed that both & and == DO comparisons
<IRBMe> however, if you did "1 & 1" then it would not be correct to say "after the comparison", but "after the bitwise &"
<aca20031> which make the comparison the action which makes the sentence just as valid.
<IRBMe> no, you say the operator name, not the action. addition operator -> "after the addition". comparison operator -> "after the comparison". & operator -> "after the bitwise and", | -> "after the bitwise or" etc
<aca20031> then why is it valid to say "after the comparison" for == and not "after the equals operators"
<IRBMe> because == is a comparison operator
<Xabster> just like <, >, >=, <=
<Xabster> and !=
<aca20031> and & COMPARES bits
<Xabster> no
<Xabster> it's AND's them
<aca20031> < > >= <= != COMPARES objects and strings and ints
<aca20031> ..
<aca20031> .AND is so not a valid verb
<Xabster> it's a bitwise AND operation, not a comparison
<aca20031> and == is a EQUALS operator
<aca20031> lol.
<Xabster> equals is a comparison operator
<aca20031> 01 & 11, compares 0 to 1, returns 0
<aca20031> compares 1 to 1, returns 1
* fukkiBcAg (~jani.kang@p5B079A05.dip0.t-ipconnect.de) has joined #java
* megabozz (~megabozz@c-71-195-158-164.hsd1.ma.comcast.net) has joined #java
<aca20031> internally it compares so fom the English non-elitest-jerk point of view
<Xabster> & does not compare
<IRBMe> aca20031, actually the operator does no such thing
<aca20031> "bitwise comparison" is a legit response
<Xabster> it performs bitwise AND
<IRBMe> logically you can think of it as doing that, but there is no comparison done in actuality
<aca20031> We're talking about sentences and names not uber-micro-management-differences
* cheek (~cheek@dslb-082-083-085-236.pools.arcor-ip.net) Quit (Ping timeout)
<aca20031> Actually, the more I think about it, I really dont care what the fuck you call the motehr fucking operator for fuck's sake! lol.
<Xabster> if you don't believe us, google it
<aca20031> I asked a question that really does not have anything to do with the names of the fucking operators
<IRBMe> no need to cuss, aca20031. Calm down
<aca20031> Can we stop arguing over the minor facist crap.
<IRBMe> Stop throwing a temper tantrum and sit in the corner until you calm down
<aca20031> psht.
* fukkiBcAg (~jani.kang@p5B079A05.dip0.t-ipconnect.de) has left #java
<IRBMe> woozle.
* IRBMe can make up words too
<aca20031> Thanks for the "help" by the way.
<IRBMe> you're "welcome"
<IRBMe> "bye" now, have a "nice" "day"
<aca20031> I asked what the difference between b and 0xFF & b was
<aca20031> and got a lecture on nothing to do with that while I found my answer in a channel not even about java.
<IRBMe> thanks for the "recap"
<IRBMe> my "buffer" isn't "working"
<IRBMe> oh wait, it "is"
<aca20031> so what are you trying to accomplish now?
<aca20031> You're getting no point across except angering me, seems liek a pretty crappy point.
<IRBMe> I'm not making any points any more
<aca20031> I'm not arguing that, when you get down to the small points you're right, sure you are
<IRBMe> Thanks for finally acknowledging that
<aca20031> I'm saying that as an English sentence "after the comparison" does not invoke 50 lines of argument :x
<IRBMe> It takes two people to argue
<IRBMe> You're just as guilty as moi
<IRBMe> If you'd rather not waste more time on it, I suggest you stop replying now
<aca20031> I have time to waste :)
<IRBMe> Then why are you bitching?
<aca20031> Just don't really care to because I know I can get no where in a programing channel, generally the people are very micro-oriented
<IRBMe> Then why did you argue?
<aca20031> unless something is 100% acurate based on how the computer itself handles binary data... :/
<aca20031> because I've seen thsi channel argue these small points with 50 different people
<aca20031> And never get around to helping them
<IRBMe> I thought you didn't care
<aca20031> didnt care about what
<aca20031> I care about people joining and asking a simple quesiton like why "long num = 123" doesnt work
<IRBMe> You tell me, you're the one who just said "Just don't really care"
<aca20031> and gfetting crap about "bigdecimal" and child porn...
<IRBMe> child porn? My, that is worrying
<IRBMe> Are you sure you're not just being spammed?
<aca20031> was earlier.
<aca20031> Really has nothing to do with you, just an annoying instance of someone not getting helped in this channel I felt I could bring up :)
<IRBMe> I suggest you take that up with an IRC operator then, and send them the hostmask of the culprit, as they may be infected with a bot or virus
<aca20031> yeah...I doubt that.
<aca20031>  http://pastebin.ca/468250
<IRBMe> Child pornography is quite a serious issue. You should perhaps contact the authorities about that too
<IRBMe> (19:34:58) <sjk\dave> well that works
<IRBMe> (19:34:59) <sjk\dave> ahhaha thanks
<IRBMe> (19:35:05) <tSh|Kietz> no problem
<IRBMe> problem solved quite quickly
<aca20031> I answer him.
<aca20031> answered*
<aca20031> Amist the child porn talk and useless arguments
<aca20031> thats my point -.-
* SPScara[BFS (~Jarnagin@server.gibt.es.bei.netlayer.eu) has joined #java
<aca20031> and again, it has nothing to do with this.
<aca20031> I jsut pasted that so you wouldnt think, as you apparantly do, that im stupid enoguh to equate someone PMing me with a virus with child porn talk in #java
<IRBMe> So what's your point? Somebody asked a question and you answered, while there was a second conversation going on...
<IRBMe> AAAAAAAAAAAAAAAND?
* Shanks\NA (Shanks@powered.by.bouncer24.de) has joined #java
<aca20031> Anyway, remind me to never ask a "I want to learn" question in here again.
* Shanks\NA (Shanks@powered.by.bouncer24.de) Quit (G-lined)
<aca20031> I'll go back to my useless sit and answer what I can existence.
<IRBMe> "I want to learn" is a statement, not a question
<aca20031> Oh that's cute.
<aca20031> Satisfied now? You got me at what would appear to be a gramatical error, except for the fact that i used it as an adjective
* dxus (nC_dxus@C22|dxus.users.quakenet.org) Quit (Ping timeout)
<aca20031> Since i don't want to be banned, which is going to happen soon enough if this keeps up lol, no hard feelings assuming we dont have another argument :) I'm just going to quit talking now
* SPScara[BFS (~Jarnagin@server.gibt.es.bei.netlayer.eu) has left #java
<IRBMe> ok bye
<IRBMe> It was a pleasure