Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: 0x8000?

 
Bigwood Liu
Ranch Hand
Posts: 240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
0x8000 is a short, but why
compile error?
Regards,
Damu
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
thank you, but 0x8000 is -32768 as complement code.
damu
[ September 22, 2003: Message edited by: damu liu ]
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi damu,
Just use an explicit typecast :

Best,
Phil.
 
Tony Morris
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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;
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic