Page 1 of 1

How to get big number

Posted: Tue May 09, 2017 1:28 am
by Kabin
I would like to implement my own wallet applet. And I want to credit 1512 , so I sent APDU

Code: Select all

CLA   INS   P1    P2    lC     DATA
80      50   00    00    02     05E8


when I use apdu.getBuffer(); to get this data, the value changes. 0xE8 is supposed to be 232, but because it supports unsigned nature, it shows a different value. What can I do to get 232 in short variable for 0xE8? Thanks for any reply.

Re: How to get big number

Posted: Tue May 09, 2017 4:46 am
by chico0609
When you have a byte that is greater than 0x7F and meanwhile you want to make it an unsigned value, you can use the following to prevent the sign extension:

Code: Select all


short a = (short) (b & 0xFF);


Re: How to get big number

Posted: Tue May 09, 2017 5:33 am
by UNKNwYSHSA
Use method makeShort(byte b1, byte b2) in package javacard.framework.Util.
short sv = Util.makeShort( (byte) 0x00, (byte) 0xE8);

Re: How to get big number

Posted: Wed May 10, 2017 10:50 pm
by Kabin
Thank you for all the help. My problem is solved. But I still have one small question. I will new another topic for easy to communicate. Thanks