commit | 6b19568b1cdd8512338ba49cd39352ace6f2a99b | [log] [tgz] |
---|---|---|
author | Daniele Moro <daniele@opennetworking.org> | Tue May 18 12:20:46 2021 +0200 |
committer | Daniele Moro <daniele@opennetworking.org> | Tue May 18 13:41:23 2021 +0000 |
tree | a647969a36a6fb480652679ff44edeba1907fc71 | |
parent | b418e111cbfa09cc66a9a8f50cf15ce8bf08ca0a [diff] |
Avoid casting to double to round-up integer division Use integer arithmetic instead Change-Id: I7b96d2aa99affad7dcd71c3212e7314cd90fb3b4 (cherry picked from commit 4807983e42463470c38ff78a5f5fa4a8010e3fc3)
diff --git a/utils/misc/src/main/java/org/onlab/util/ImmutableByteSequence.java b/utils/misc/src/main/java/org/onlab/util/ImmutableByteSequence.java index 4794a24..013f3c5 100644 --- a/utils/misc/src/main/java/org/onlab/util/ImmutableByteSequence.java +++ b/utils/misc/src/main/java/org/onlab/util/ImmutableByteSequence.java
@@ -432,7 +432,7 @@ checkNotNull(original, "byte sequence cannot be null"); checkArgument(bitWidth > 0, "bit-width must be a non-zero positive integer"); - int newByteWidth = (int) Math.ceil((double) bitWidth / 8); + int newByteWidth = (bitWidth + 7) / 8; if (bitWidth == original.size() * 8) { // No need to fit.