JavacardOS will not accept order any more, please contact our partner Feitian online Store:
https://ftsafe.en.alibaba.com/index.html

How to get big number

JavaCard Applet Development Related Questions and Answers.
Kabin
Posts: 9
Joined: Tue Apr 18, 2017 3:51 am
Points :116
Contact:

How to get big number

Post by Kabin » Tue May 09, 2017 1:28 am

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.

chico0609
Posts: 59
Joined: Mon Sep 14, 2015 5:05 am
Points :416
Contact:

Re: How to get big number

Post by chico0609 » Tue May 09, 2017 4:46 am

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);


User avatar
UNKNwYSHSA
Posts: 630
Joined: Thu May 21, 2015 4:05 am
Points :3053
Contact:

Re: How to get big number

Post by UNKNwYSHSA » Tue May 09, 2017 5:33 am

Use method makeShort(byte b1, byte b2) in package javacard.framework.Util.
short sv = Util.makeShort( (byte) 0x00, (byte) 0xE8);
sense and simplicity

Kabin
Posts: 9
Joined: Tue Apr 18, 2017 3:51 am
Points :116
Contact:

Re: How to get big number

Post by Kabin » Wed May 10, 2017 10:50 pm

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

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: Bing [Bot] and 35 guests

JavaCard OS : Disclaimer