2024年3月12日发(作者:)

NumberUtil数字工具类

NumberUtil类的成员方法(详情请参考具体内容介绍):

方法名

format

参数

Number,String

描述

以参数format指定的格式格式化参

数n

getBinaryList

int

传入指定数字,返回对应的二进制数

getBinaryString

getRandomInt

isDouble

isFloat

isInt

isInteger

isLong

isNumber

main

round

toBytes

toBytes

toBytes

int

int

String

String

String

String

String

String

String[]

Double,int

int

long

Int,byte[],int

传入指定数字,返回对应的字符串

在0-max范围内获取随机整数

是否是双字节浮点数

是否是浮点数

是否是整形数据

是否是整形数据

是否是长整形数据

是否是数字

主函数

四舍五入

整型转为二进制

长整型转为8位二进制

整型转为4位二进制数,写入到指定

数组的指定位置

toBytes

long,byte[],int

长整型转为8位二进制数,写入到指

定数组的指定位置

toBytes

short

短整型转为二进制

toBytes

short,byte[],int

短整型转为2位二进制数,写入到指

定数组的指定位置

toInt

toInt

byte[]

Byte[],int

二进制转为整型

从指定位置开始读取4位二进制,转

换为整型

toLong

toLong

Byte[]

Byte[],int

二进制转长整型

从指定数据的指定位置开始,读取8

位二进制,转为长整型

toShort

toShort

Byte[]

Byte[],int

读取2位二进制,转为短整型

从指定数组的指定位置开始,读取2

位二进制,转为短整型

Format(Number,String)

以参数format指定的格式格式化参数n。

代码实例

intn=2343656;

Stringformat="###,###,###";

Stringb=(n,format);//2,343,656

getBinaryList(int)

返回一个指定为Integer泛型的ArrayList。

代码实例

intn=234;

ArrayListb=aryList(n);//[128,64,32,8,2]

getBinaryString(int)

指传入指定数字,返回对应的二进制数组,再将其转化为String。

代码实例

intn=234;

Stringb=aryString(n);//128,64,32,8,2

getRandomInt(int)

在0-max范围内获取随机整数。