mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-10-04 19:42:01 +08:00
修复bytehelper & VlInt中的已知bug
This commit is contained in:
1 parent
227d10a391
commit
2ad446ca2c
29 files changed
+315
-80
No files matched your search
@@ -4,6 +4,7 @@ package encoding;
|
||||
import util.ByteHelper;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static java.lang.Math.pow;
|
||||
|
||||
@@ -117,22 +118,23 @@ public class VlInt {
|
||||
* 将vlint转为一个int输出:需要判断size是不是小于4(1 or 3)
|
||||
* @return
|
||||
*/
|
||||
public int getVlIntValue2Int(){
|
||||
public int getVlIntValue2Int() throws VlIntException {
|
||||
if(this.size()<4){
|
||||
return VlIntValue.intValue();
|
||||
}
|
||||
return Integer.parseInt(null);
|
||||
throw new VlIntException("value大于int能表示的范围");
|
||||
}
|
||||
|
||||
/**
|
||||
* 将vlint转为一个long输出:需要判断size是不是小于8(5)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public long getVlIntValue2Long(){
|
||||
if(this.size()<8){
|
||||
public long getVlIntValue2Long() throws VlIntException {
|
||||
if(this.size()<= 9){
|
||||
return VlIntValue.longValue();
|
||||
}
|
||||
return Long.parseLong(null);
|
||||
throw new VlIntException("value大于long能表示的范围");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -190,8 +192,8 @@ public class VlInt {
|
||||
* @param vlInt
|
||||
* @return
|
||||
*/
|
||||
public int subtract(VlInt vlInt){
|
||||
return this.VlIntValue.subtract(vlInt.VlIntValue).intValue();
|
||||
public long subtract(VlInt vlInt){
|
||||
return this.VlIntValue.subtract(vlInt.VlIntValue).longValue();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -199,11 +201,11 @@ public class VlInt {
|
||||
* @param vlInt
|
||||
* @return
|
||||
*/
|
||||
public int add(VlInt vlInt){
|
||||
return this.VlIntValue.add(vlInt.VlIntValue).intValue();
|
||||
public long add(VlInt vlInt){
|
||||
return this.VlIntValue.add(vlInt.VlIntValue).longValue();
|
||||
}
|
||||
public int add(int i_int){
|
||||
return this.VlIntValue.intValue()+i_int;
|
||||
public long add(int i_int){
|
||||
return this.VlIntValue.longValue()+i_int;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -263,6 +265,16 @@ public class VlInt {
|
||||
return vlintValue;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "VlInt{" +
|
||||
"VlIntBytes=" + Arrays.toString(VlIntBytes) +
|
||||
", VlIntValue=" + VlIntValue +
|
||||
", size=" + size +
|
||||
'}';
|
||||
}
|
||||
|
||||
// 测试
|
||||
public static void main(String[] args){
|
||||
// BigInteger bigInteger=new BigInteger("3");
|
||||
|
||||
Reference in new issue
Block a user