This is not a Support area! Discuss about the Server here. Non-Server related discussion goes in
Off-Topic Discussion.
brutus
Posts: 325 Joined: Sat Nov 10, 2007 4:18 pm
Location: Bulgaria
Post
by brutus » Fri Jun 04, 2010 9:27 pm
hey, check the code below! isnt that weird cuz the hexadecimal of 0xffffffff is out of range for Integer and int of 0xffffffff is -1
Code: Select all
private int _objectId; if (_objectId == 0xFFFFFFFF) { // Player canceled enchant player.setActiveEnchantAttrItem(null); player.sendPacket(new SystemMessage(SystemMessageId.ELEMENTAL_ENHANCE_CANCELED)); return; }
JIV
L2j Veteran
Posts: 1882 Joined: Sun Jan 06, 2008 8:17 pm
Location: Slovakia
Contact:
Post
by JIV » Sat Jun 05, 2010 12:07 am
if (_objectId == 0xFFFFFFFF)
and
if (_objectId == -1)
is same. or what is the question?
brutus
Posts: 325 Joined: Sat Nov 10, 2007 4:18 pm
Location: Bulgaria
Post
by brutus » Sat Jun 05, 2010 1:13 pm
JIV wrote: if (_objectId == 0xFFFFFFFF)
and
if (_objectId == -1)
is same. or what is the question?
exactly, thats what i asked
so you guys use out of range ints to get the -1?
thank you anyways
JIV
L2j Veteran
Posts: 1882 Joined: Sun Jan 06, 2008 8:17 pm
Location: Slovakia
Contact:
Post
by JIV » Sat Jun 05, 2010 4:39 pm
its not out of range.
brutus
Posts: 325 Joined: Sat Nov 10, 2007 4:18 pm
Location: Bulgaria
Post
by brutus » Sat Jun 05, 2010 4:51 pm
JIV wrote: its not out of range.
isnt 0xFFFFFFFF = 4294967295 ?
max int is 2.147..
JIV
L2j Veteran
Posts: 1882 Joined: Sun Jan 06, 2008 8:17 pm
Location: Slovakia
Contact:
Post
by JIV » Sat Jun 05, 2010 4:56 pm
that depends on how many bytes you have
brutus
Posts: 325 Joined: Sat Nov 10, 2007 4:18 pm
Location: Bulgaria
Post
by brutus » Sat Jun 05, 2010 5:11 pm
JIV wrote: that depends on how many bytes you have
anyways, it was a stupid question
as you said its not out of range since Integer contains all positive and negative numbers and the total is 0xFFFFFFFF
i didnt thought that the objectid can be -1 thats why i asked.. thanks for your time
wasabi2k
Posts: 110 Joined: Sun Oct 08, 2006 4:22 pm
Post
by wasabi2k » Sat Jun 05, 2010 11:05 pm
brutus wrote: JIV wrote: its not out of range.
isnt 0xFFFFFFFF = 4294967295 ?
max int is 2.147..
this is wrong cuz INT is a signed integer which means that the last bit is used to say whereather it is negative or positive thats why the max size of a 32bit integer is 2^31 and not 2^32 since it needs a bit for negative values.
also if i am correct negative integers count the opposite way of positive integers so 0x00000001 = 1 and 0x00000002 = 2 but for negative its 0xFFFFFFFF = -1 and 0xFFFFFFFD = -2
i hope my explenation is clear D: