commit | 4807983e42463470c38ff78a5f5fa4a8010e3fc3 | [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 12:21:12 2021 +0200 |
tree | 473048bc919ce453d32c01431832ff6f216049a3 | |
parent | 7388cdc71ef0d14df3295a581070424ba84ce7f0 [diff] |
Avoid casting to double to round-up integer division Use integer arithmetic instead Change-Id: I7b96d2aa99affad7dcd71c3212e7314cd90fb3b4
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.