This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Hi,
On Tue, 2004-09-28 at 03:04, Jerry Quinn wrote:
> + private BigInteger validBits = new BigInteger("0");
>
[...]
> +
> + // Generate a bigint with 1's for every pixel
> + validBits.setBit(size);
> + validBits.subtract(new BigInteger("1"));
>
Note that there is BigInteger.ZERO and BigInteger.ONE which you can use
here so you don't have to create a new object. Also the static method
BigInteger.valueOf(long) is preferred since it can return a pre-existing
BigInteger so no new object needs to be created.
You can do this because BigIntegers are immutable. This also means that
you have to be careful in this code and notice that methods like
setBit() and substract() don't change the BigInteger they are called on,
but return a new BigInteger. There are a couple of places in this code
that should be written like: validBits = validBits.setBit(size);
Cheers,
Mark
Attachment:
signature.asc
Description: This is a digitally signed message part
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |