aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX: 0x8000? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "NX: 0x8000?" Watch "NX: 0x8000?" New topic
Author

NX: 0x8000?

Bigwood Liu
Ranch Hand

Joined: Feb 26, 2003
Posts: 240
Hi,
0x8000 is a short, but why
compile error?
Regards,
Damu
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937
0x8000 is 32768, and you are trying to assign it to a variable of type short whose range is from -32768 to 32767. The compiler warns you about the loss of precision.
Bigwood Liu
Ranch Hand

Joined: Feb 26, 2003
Posts: 240
Hi,
thank you, but 0x8000 is -32768 as complement code.
damu
[ September 22, 2003: Message edited by: damu liu ]
Philippe Maquet
Bartender

Joined: Jun 02, 2003
Posts: 1872
Hi damu,
Just use an explicit typecast :

Best,
Phil.
Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
why not a char even ?
public interface DataFileConstants
{
/**
* The 2 byte flag value of a record that indicates that it is valid (not deleted).
*/
public static final char VALID_RECORD = 0x0000;
/**
* The 2 byte flag value of a record that indicates that it has been deleted.
*/
public static final char DELETED_RECORD = 0x8000;
}


Tony Morris
Java Q&A (FAQ, Trivia)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NX: 0x8000?
 
Similar Threads
NX: Flag help
UrlyBird with data file record deletions
Magic Cookie checking and deleted flag
magic cookie and 0x800 flag doubt
short s = 0x8000 gives compiler error