在java中是否有任何标准方法可以将IBM 370(以字节的形式)转换为IEEE格式.任何转换算法都有帮助..
我试着写一个java代码..但我不明白我哪里出错了.当我输入为-2.000000000000000E + 02时,我的IEEE格式为-140.0.在其他情况下,当我输入3.140000000000000E + 00时,我得到IEEE格式的3.1712502374909226值任何帮助都将受到高度赞赏
private void conversion() {
byte[] buffer = //bytes to be read(8 bytes);
int sign = (buffer[0] & 0x80);
// Extract exponent.
int exp = ((buffer[0] & 0x7f) - 64) * 4 - 1;
//Normalize the mantissa.
for (int i = 0; i < 4; i++) {//since 4 bits per hex digit
if ((buffer[1] & 0x80) == 0) {
buffer = leftShift(buffer);
exp = exp - 1;
}
}
// Put sign and mantissa …
Run Code Online (Sandbox Code Playgroud)