我在将short
值转换为double
Java 时遇到问题。我将实数表示为 16 位无符号值(short
在 java 中)。当我阅读它们时,我想将它们转换为double
,但在执行之后(double) value
,我得到了错误的结果,例如在一种情况下使用System.out.println(value)
I get 0.0
,但结果应该是0.00034
。
double[][] dataD = null;
short[][] dataS = null;
try {
fits = new Fits(path); // here im readinf fits file
switch(bitpix) { // bitpix contains information about size of data
case 16: dataS = ((short[][]) fits.getHDU(0).getKernel()); break;
...
}
} catch (FitsException e) {}
catch (IOException e) {}
for( int i = 0; i < dataS.length; i++ )
for( int j = 0 ; j <dataS[0].length ; j++ ) {
switch(bitpix) {
case 16: dataD[i][j] = 0.0;
if( dataS[i][j] < 0 ) dataD[i][j] = dataS[i][j] + 32768;
else dataD[i][j] = dataS[i][j] ;
break;
}