Package nom.tam.fits.utilities
Class FitsCheckSum
java.lang.Object
nom.tam.fits.utilities.FitsCheckSum
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
private static final int
private static final int
private static final Logger
logger to log to. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic long
checksum
(byte[] data) Calculate the Seaman-Pence 32-bit 1's complement checksum over the byte stream.static String
checksumEnc
(long c, boolean compl) Encode a 32bit integer according to the Seaman-Pence proposal.static void
setChecksum
(BasicHDU<?> hdu) Add or update the CHECKSUM keyword.
-
Field Details
-
CHECKSUM_STRING_SIZE
private static final int CHECKSUM_STRING_SIZE- See Also:
-
LOG
logger to log to. -
CHECKSUM_BLOCK_SIZE
private static final int CHECKSUM_BLOCK_SIZE- See Also:
-
CHECKSUM_HALF_BLOCK_SIZE
private static final int CHECKSUM_HALF_BLOCK_SIZE- See Also:
-
-
Constructor Details
-
FitsCheckSum
private FitsCheckSum()
-
-
Method Details
-
checksum
public static long checksum(byte[] data) Calculate the Seaman-Pence 32-bit 1's complement checksum over the byte stream. The option to start from an intermediate checksum accumulated over another previous byte stream is not implemented. The implementation accumulates in two 64-bit integer values the two low-order and the two high-order bytes of adjacent 4-byte groups. A carry-over of bits is never done within the main loop (only once at the end at reduction to a 32-bit positive integer) since an overflow of a 64-bit value (signed, with maximum at 2^63-1) by summation of 16-bit values could only occur after adding approximately 140G short values (=2^47) (280GBytes) or more. We assume for now that this routine here is never called to swallow FITS files of that size or larger. by R J MatharChecksum.CHECKSUM
- Parameters:
data
- the byte sequence- Returns:
- the 32bit checksum in the range from 0 to 2^32-1
- Since:
- 2005-10-05
-
checksumEnc
Encode a 32bit integer according to the Seaman-Pence proposal.- Parameters:
c
- the checksum previously calculatedcompl
- complement the value- Returns:
- the encoded string of 16 bytes.
- See Also:
-
setChecksum
Add or update the CHECKSUM keyword. by R J Mathar- Parameters:
hdu
- the HDU to be updated.- Throws:
FitsException
- if the operation failed- Since:
- 2005-10-05
-