Page 1 of 1

How to make integer variable on JavaCard 2.2.2?

Posted: Sat Dec 05, 2015 4:24 am
by Erisaron
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!

Re: How to make integer variable on JavaCard 2.2.2?

Posted: Sun Dec 06, 2015 11:51 pm
by UNKNwYSHSA
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.

Re: How to make integer variable on JavaCard 2.2.2?

Posted: Thu Oct 12, 2017 5:11 am
by vasilis
Just a heads up that JCMathLib also provides an Integer class. :)

Re: How to make integer variable on JavaCard 2.2.2?

Posted: Sun Jan 27, 2019 11:14 am
by owlstead
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.

Re: How to make integer variable on JavaCard 2.2.2?

Posted: Sat Feb 02, 2019 1:43 am
by nishakale
Excellent topic. I learned a lot. Thank you very much for sharing.
https://crbtech.in/online-java-training-course