>From JavaCard Technology for smartcards, p209 :-
In a function
add(byte[] A, byte AOff, byte[] B, byte BOff, byte[] C, byte COff, byte len)
where C= A + B:
----------
short result = 0;
for (len = (byte)(len - 1); len >= 0; len--)
{
result= (short)(getUnsignedByte(A,AOff, len)
+ getUnsignedByte(B, BOff, len)
+ result);
C[(short)(len + COff)] = (byte)(result);
if(result > 0x00FF)
result = 1;
else
result = 0;
}
if(result == 1)
// Overflow
----------
You will have to get the for loop to work the other way through the arrays if
you are using little endian storage.
Hope this helps.
Martin Ellis
On Thu, 01 Feb 2001, Jorge Lanza wrote:
> I'm developing a JavaCard aplication in which I need numbers bigger than
> shorts. So the solution I've found is, storing the number as an array of
> bytes. However I've come up with the problem of how to add them.
> Has anybody had that kind of problem? Any help is welcome.
>
>
>
> ---
> > Visit the OpenCard web site at http://www.opencard.org/ for more
> > information on OpenCard---binaries, source code, documents.
> > This list is being archived at http://www.opencard.org/archive/opencard/
>
> ! To unsubscribe from the [EMAIL PROTECTED] mailing list send an email
> ! to
> ! [EMAIL PROTECTED]
> ! containing the word
> ! unsubscribe
> ! in the body.
---
> Visit the OpenCard web site at http://www.opencard.org/ for more
> information on OpenCard---binaries, source code, documents.
> This list is being archived at http://www.opencard.org/archive/opencard/
! To unsubscribe from the [EMAIL PROTECTED] mailing list send an email
! to
! [EMAIL PROTECTED]
! containing the word
! unsubscribe
! in the body.