mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-10-04 19:42:01 +08:00
add test: TLVTest
This commit is contained in:
1 parent
adf834a4e9
commit
8a42d7a7de
3 files changed
+80
-9
No files matched your search
@@ -39,6 +39,10 @@ public class VlInt {
|
||||
public static final int VlIntSize5=5;
|
||||
public static final int VlIntSize9=9;
|
||||
|
||||
public static final long uint16Max= (long) (pow(2, 16)-1);
|
||||
public static final long uint32Max= (long) (pow(2, 32)-1);
|
||||
public static final long uint64Max= Long.MAX_VALUE; //MIN1.0中此数用long的最大值表示
|
||||
|
||||
/**
|
||||
* 测量一个变长整型实际用几个字节表示
|
||||
* @return
|
||||
@@ -52,15 +56,11 @@ public class VlInt {
|
||||
}
|
||||
if(bigInteger.compareTo(BigInteger.valueOf(241)) < 0){
|
||||
return 1;
|
||||
}else if(bigInteger.compareTo(BigInteger.valueOf(
|
||||
new Double(pow(2, 16)).longValue())) < 0){
|
||||
}else if(bigInteger.compareTo(BigInteger.valueOf(uint16Max)) <= 0){
|
||||
return 3;
|
||||
}else if(bigInteger.compareTo(BigInteger.valueOf(
|
||||
new Double(pow(2, 32)).longValue())) < 0){
|
||||
}else if(bigInteger.compareTo(BigInteger.valueOf(uint32Max))<= 0){
|
||||
return 5;
|
||||
}else if(bigInteger.compareTo(BigInteger.valueOf(
|
||||
new Double(pow(2, 64)).longValue())) <= 0){
|
||||
// 这里其实是与long的最大值做对比,所以可以等
|
||||
}else if(bigInteger.compareTo(BigInteger.valueOf(uint64Max)) <= 0){
|
||||
return 9;
|
||||
}else{
|
||||
//MIN1.0中,VlInt的size最大为9
|
||||
@@ -287,6 +287,7 @@ public class VlInt {
|
||||
|
||||
/**
|
||||
* 将BigInteger转为byte[按照变长无符号整数方式转]
|
||||
*
|
||||
* @param bigInteger
|
||||
* @return
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user