Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert byte to short in JavaCard

In java card only small data types are used (byte and short). I am trying to convert byte to short such that i can use it for checking condition,etc. When byte is converted into short using type cast in java card it gives me some other negative number. Please tell me how to convert (11111111) that is ff store in single byte to short.

I am using:

  1. smart card type = contact card
  2. using java card 2.2.2
  3. with jcop using apdu
like image 571
Sachin D Avatar asked Dec 11 '25 19:12

Sachin D


2 Answers

Isn't the Java Card language simply the same as Java? Then you can write

shortvar = bytevar&0xFF;

like image 177
Mr Lister Avatar answered Dec 13 '25 07:12

Mr Lister


You can use javacard.framework.Util.makeShort(byte b1, byte b2) method.

like image 30
MikhailDudarev Avatar answered Dec 13 '25 09:12

MikhailDudarev