Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

magic cookie and 0x800 flag doubt

 
Jeffry Kristianto Yanuar
Ranch Hand
Posts: 759
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys, my name is Jeffry. Today I download the URLyBird 1.3.2 project assignment and I already figure out how to read the contents of the file provided with the assignment.

When my program read 4 bytes for magic cookies, it show strange number that doesn't make sense to me, while the other bytes such as offset, number of fields, etc show the correct number. What is the purpose of magic cookie?

I also read a part in my assignment that shows like this:

Repeat to end of file:
2 byte flag. 00 implies valid record, 0x8000 implies deleted record


What is "0x8000" and "00" ? Is that a String or number or what ?


Thanks


Jeffry Kristianto Yanuar
SCJP 5.0
SCJA
SCJD (Working on URLyBird 1.3.2)
 
Marco Ehrentreich
best scout
Bartender
Posts: 1294
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeffry,

I don't really know this assignment but 0x is used as a prefix to numbers in hexadecimal notation. So you have the hexadecimal numbers 0000 (= 0 decimal) and 8000 (= 32768 decimal). In your case it seems that the corresponding decimal value isn't that important. The two bytes (4 digits in hex correspond to 2 bytes) are probably just used to signal the current state of these records.

Marco

[ June 28, 2008: Message edited by: Marco Ehrentreich ]
[ June 28, 2008: Message edited by: Marco Ehrentreich ]
 
Jeffry Kristianto Yanuar
Ranch Hand
Posts: 759
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What about magic cookie? I tried read the 0x8000 as a short (2 bytes) and it prints -32768. Which one is right? look at the code




Thanks Friends

Jeffry Kristianto Yanuar
SCJP 5.0
SCJA
SCJD (Working on UrlyBird 1.3.2)
 
Marco Ehrentreich
best scout
Bartender
Posts: 1294
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The concrete decimal interpretation of the binary value depends on the number of bits the type of a variable can hold and if the type is a signed or un-signed type. You can find more information on this here.

Marco
 
Jeffry Kristianto Yanuar
Ranch Hand
Posts: 759
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks friends. Did you already SCJD?
 
Marco Ehrentreich
best scout
Bartender
Posts: 1294
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, I don't have any certifications yet. But I'm thinking about doing the SCJD exam at the end of year... Unfortunately I don't find enough time for this at the moment.

Anyway I wish you good luck for your exam

Marco
 
Jeffry Kristianto Yanuar
Ranch Hand
Posts: 759
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, thanks. IF you don't have much time to SCJD then consider to take SCWCD.


Thanks

Jeffry Kristianto Yanuar
SCJP 5.0
SCJA
SCJD (Working on UrlyBird 1.3.2)
 
Marco Ehrentreich
best scout
Bartender
Posts: 1294
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeffry,

I have less experience in Java web development, so I think I would most probably take the SCJP and SCJD exams first. But just out of curiosity do you really think the SCWCD exam is easier to prepare for?

Marco
 
Jeffry Kristianto Yanuar
Ranch Hand
Posts: 759
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I think SCWCD is easier than SCJD because it only involving theory based exam.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic