[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orekit Developers] JPL ephemerides files endianness detection



Hello,

I am currently cleaning up code, removing checkstyle, findbugs and javadoc warnings. In the process, I noticed the following problem.

The latest JPL ephemerides loader class includes a binary file endianness detection, which I think was ported from calceph. Detection is based on the following statement:

// simple heuristic: if the read value is larger than half the range of an integer
//                 assume the file is in little-endian format
if ((deNum & 0xffffffffL) > (1 << 15)) {
     bigEndian = false;
}

where deNum is an int.

Findbugs complains about the test, it consider it is a "Check for sign of bitwise operation", explained here: <http://findbugs.sourceforge.net/bugDescriptions.html#BIT_SIGNED_CHECK>.

I think that we could get rid of the error by removing the bit mask in the test as follows:

if (deNum > (1 << 15)) {
     bigEndian = false;
}

Since deNum is an int and Java ints are known to be 32 bits, I think the mask does not serve any purpose. I didn't look at calceph code, but think such a test is useful when using uint64 C type or similar.

Does anybody has an opinion about this ?

Luc

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.