Skip to content

liangguangming/ieee-754

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ieee-754

样例: // 第一种实现方式,完全按照 IEEE 754 规范而写
十进制单精度浮点数(32bit)转16进制:IEEE754.singleFloatToHex(10.125);
十进制双精度浮点数(62bit)转16进制:IEEE754.doubleFloatToHex(10.125);
16进制转十进制单精度浮点数(32bit):IEEE754.hexToSingleFloat('0x0000ffef');
16进制转十进制双精度浮点数(62bit):IEEE754.doubleFloatToHex('0x000000000000ffef');

// 第二种实现方式,利用 TypeArray 能力
十进制单精度浮点数(32bit)转16进制:IEEE754_NEW.singleFloatToHex(10.125);
十进制双精度浮点数(62bit)转16进制:IEEE754_NEW.doubleFloatToHex(10.125);
16进制转十进制单精度浮点数(32bit):IEEE754_NEW.hexToSingleFloat('0x0000ffef');
16进制转十进制双精度浮点数(62bit):IEEE754_NEW.doubleFloatToHex('0x000000000000ffef');

About

IEEE-754 浮点精度转换的实现

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published