can i represent 128 bit number in java? or in c++?

In Java, you can use the BigInteger class to store arbitrarily large integers. In C++ you can use a library like GMP to get the same functionality.

Write your own class and operations for representing 128 bit numbers or use some library available.

The `BigInteger`

class is designed for integer values bigger then `Long.MAX_VALUE`

.

You can. You will most likely need to use a library to do this though, at least for C++.

I like the PolarSSL library or the GNU MP Bignum library.

Of course you can represent them.

At *least* you can use a byte-array with 16 elements.

However, the question is if you just want to *represent* the value or actually do some *calculations* with it.

In Java you can use `BigInteger`

to represent (effectively) arbitrary sized integer values *and* do calculations as well.

**java.math.BigInteger**

To work with integers that are larger than 64 bits (the size of a long), use java.math.BigInteger. This class represents unbounded integers and provides a number of methods for doing arithmetic with them.

http://leepoint.net/notes-java/data/numbers/10biginteger.html

If you need decimal values use **BigDecimal**

Of course, you can use **BigInteger** class in java.math package.
This class provides operations for modular arithmetic, GCD calculation, primality testing, prime generation, bit manipulation like operations.

This class has been added in **JDK1.1** itself.

But I don't know there is such a availability built into with C++ library. There can be a extensible API from third parties.