Skip to content

Commit 652f338

Browse files
committed
Update readme and javadoc
1 parent cb1b7f0 commit 652f338

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Bit-lib4j [![Build Status](https://travis-ci.org/devnied/Bit-lib4j.png?branch=ma
44
Bit-Lib4j is an useful library to handle bytes or bits in Java.<br/>
55
With this library you can read/write data in a byte array with a custom size for Java primitive types.
66

7-
<b>Current version : 1.4.10</b>
7+
<b>Current version : 1.4.11</b>
88

99
##Simple API
1010

@@ -44,7 +44,7 @@ More documentation into the [wiki](https://github.com/devnied/Bit-lib4j/wiki)
4444
<dependency>
4545
<groupId>com.github.devnied</groupId>
4646
<artifactId>bit-lib4j</artifactId>
47-
<version>1.4.10</version>
47+
<version>1.4.11</version>
4848
</dependency>
4949
```
5050

src/main/java/fr/devnied/bitlib/BitUtils.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -518,12 +518,21 @@ public void setNextHexaString(final String pValue, final int pLength) {
518518
* the length of the long
519519
*/
520520
public void setNextLong(final long pValue, final int pLength) {
521-
long value = pValue;
522521

523-
if (pLength > 64) {
524-
throw new IllegalArgumentException("Overflow with length > 64");
522+
if (pLength > Long.SIZE) {
523+
throw new IllegalArgumentException("Long overflow with length > 64");
525524
}
526525

526+
setNextValue(pValue, pLength);
527+
}
528+
529+
/**
530+
* Add Value to the current position with the specified size
531+
* @param pValue value to add
532+
* @param pLength length of the value
533+
*/
534+
protected void setNextValue(final long pValue, final int pLength){
535+
long value = pValue;
527536
// Set to max value if pValue cannot be stored on pLength bits.
528537
if (pValue >= 1 << pLength) {
529538
value = (1 << pLength) - 1;
@@ -559,11 +568,11 @@ public void setNextLong(final long pValue, final int pLength) {
559568
*/
560569
public void setNextInteger(final int pValue, final int pLength) {
561570

562-
if (pLength > 32) {
571+
if (pLength > Integer.SIZE) {
563572
throw new IllegalArgumentException("Integer overflow with length > 32");
564573
}
565574

566-
setNextLong(pValue, pLength);
575+
setNextValue(pValue, pLength);
567576
}
568577

569578
/**

0 commit comments

Comments
 (0)