[英]Convert byte to short in JavaCard
In java card only small data types are used (byte and short). 在java卡中,仅使用小数据类型(字节和短)。 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.
当使用java卡中的类型转换将字节转换为short时,它会给我一些其他负数。 Please tell me how to convert (11111111) that is ff store in single byte to short.
请告诉我如何转换(11111111)ff存储在单字节到短。
I am using: 我在用:
您可以使用javacard.framework.Util.makeShort(字节b1,字节b2)方法。
Isn't the Java Card language simply the same as Java? Java Card语言与Java是否完全相同? Then you can write
然后你就可以写了
shortvar = bytevar&0xFF;
我知道你已经回答了,但据我所知,好的方法是使用javacard.framework.Util makeShort方法,当你给2个字节时它会返回短路。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.