How to make integer variable on JavaCard 2.2.2?

JavaCard Applet Development Related Questions and Answers.
Erisaron
Posts: 15
Joined: Wed Dec 02, 2015 1:23 am
Points :64
Contact:

How to make integer variable on JavaCard 2.2.2?

Post by Erisaron » Sat Dec 05, 2015 4:24 am

As far as I know, there is no integer variable on JavaCard 2.2.2. Am I right? I am developing an applet which needs int variable and four basic arithmetic operations + - * / .

I want to know how to make the int variable and process the four basic arithmetic operations. Any help? I am much appreciated!

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

Re: How to make integer variable on JavaCard 2.2.2?

Post by UNKNwYSHSA » Sun Dec 06, 2015 11:51 pm

The card need to support JCint.
For your applet compatibility, implement JCint yourself in your applet.
Currently issued cards support JCint generally, few are not support.
sense and simplicity

vasilis
Posts: 2
Joined: Fri Sep 15, 2017 8:56 am
Points :20
Contact:

Re: How to make integer variable on JavaCard 2.2.2?

Post by vasilis » Thu Oct 12, 2017 5:11 am

Just a heads up that JCMathLib also provides an Integer class. :)

owlstead
Posts: 9
Joined: Sun Jan 27, 2019 10:57 am
Points :28
Contact:

Re: How to make integer variable on JavaCard 2.2.2?

Post by owlstead » Sun Jan 27, 2019 11:14 am

There is no direct way when using the API. The answer that JCInt is generally supported is complete bollocks, most cards won't support the int type after all. One option is to use a generic BigNum library such as JCMathLib (which operates on any sized number). If you are lucky then BigNum support is build in using the BigNumber API. I would not count on availability for generic cards though.

It is of course also possible to program it yourself - to a certain degree. Which is exactly what I did in my JCInteger class posted on StackOverflow, link here. Note that the multiplication, division and remainder ops are not things that are easy to program efficiently. Even with this highly optimized code, you will want to avoid using the class - use short where you can. It does require some awkward juggling with types, as any object is in EEPROM for Java Card.

nishakale
Posts: 2
Joined: Fri Feb 01, 2019 1:28 am
Points :18
Contact:

Re: How to make integer variable on JavaCard 2.2.2?

Post by nishakale » Sat Feb 02, 2019 1:43 am

Excellent topic. I learned a lot. Thank you very much for sharing.
https://crbtech.in/online-java-training-course

Post Reply Previous topicNext topic

Who is online

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

JavaCard OS : Disclaimer