Very Large Integer

Would this be the fastest way to add two very large number with a result that is say a 256 byte number? Curious for a RSA-2048 encryption which uses a 256 byte number. Though the RSA encryption is a large prime * a large prime.

1
2
3
4
5
6
while( rhs.any() )
{
    carry = ( lhs & rhs ) << 1;
    lhs ^= rhs;
    rhs = carry;
}


Example of 4 + 4:

0100 + 0100 = ??

round 1:
carry = 1000
lhs = 0000
rhs = 1000
rhs has 0 bits set

answer is now 1000 = 8

*small typo
Last edited on
Topic archived. No new replies allowed.