diff options
author | RichieSams | 2015-01-07 07:00:13 -0600 |
---|---|---|
committer | RichieSams | 2015-01-07 07:00:13 -0600 |
commit | 4c64f7e194e5ce74a9213ef09648e615f3661de6 (patch) | |
tree | 6097966936dc511dcb7857444d235a23f05b23f8 /engines/sword25/util | |
parent | 4ffaf4df376e6d93c1b5c4c820c975fdee64ec8f (diff) | |
download | scummvm-rg350-4c64f7e194e5ce74a9213ef09648e615f3661de6.tar.gz scummvm-rg350-4c64f7e194e5ce74a9213ef09648e615f3661de6.tar.bz2 scummvm-rg350-4c64f7e194e5ce74a9213ef09648e615f3661de6.zip |
SWORD25: Remove unused code
The original idea was to keep the code variation and pick the best one. However,
these two methods we're portable enough for our needs.
Diffstat (limited to 'engines/sword25/util')
-rw-r--r-- | engines/sword25/util/double_serialization.cpp | 76 | ||||
-rw-r--r-- | engines/sword25/util/double_serialization.h | 37 |
2 files changed, 0 insertions, 113 deletions
diff --git a/engines/sword25/util/double_serialization.cpp b/engines/sword25/util/double_serialization.cpp index a34eb0fbff..73da296e40 100644 --- a/engines/sword25/util/double_serialization.cpp +++ b/engines/sword25/util/double_serialization.cpp @@ -65,80 +65,4 @@ double decodeDouble(SerializedDouble value) { return ((value.signAndSignificandTwo & 0x80000000) == 0x80000000) ? -returnValue : returnValue; } -#if 0 - -// Why these are needed? - -uint64 encodeDouble_64(double value) { - // Split the value into its significand and exponent - int exponent; - double significand = frexp(value, &exponent); - - // Shift the significand into the integer range - double shiftedsignificand = ldexp(abs(significand), 53); - - // Combine everything using the IEEE standard - uint64 uintsignificand = (uint64)shiftedsignificand; - return ((uint64)(value < 0 ? 1 : 0) << 63) | // Sign - ((uint64)(exponent + 1023) << 52) | // Exponent stored as an offset to 1023 - (uintsignificand & 0x000FFFFFFFFFFFFFLL); // significand with MSB inferred -} - -double decodeDouble_64(uint64 value) { - // Expand the exponent and significand - int exponent = (int)((value >> 52) & 0x7FF) - 1023; - double expandedsignificand = (double)(0x10000000000000LL /* Inferred MSB */ | (value & 0x000FFFFFFFFFFFFFLL)); - - // Deflate the significand - int temp; - double significand = frexp(expandedsignificand, &temp); - - // Re-calculate the actual double - double returnValue = ldexp(significand, exponent); - - // Check the sign bit and return - return ((value & 0x8000000000000000LL) == 0x8000000000000000LL) ? -returnValue : returnValue; -} - -CompactSerializedDouble encodeDouble_Compact(double value) { - // Split the value into its significand and exponent - int exponent; - double significand = frexp(value, &exponent); - - // Shift the the first part of the significand into the integer range - double shiftedsignificandPart = ldexp(abs(significand), 32); - uint32 significandOne = uint32(floor(shiftedsignificandPart)); - - // Shift the remainder of the significand into the integer range - shiftedsignificandPart -= significandOne; - uint32 significandTwo = (uint32)(ldexp(shiftedsignificandPart, 21)); - - CompactSerializedDouble returnValue; - returnValue.signAndSignificandOne = ((uint32)(value < 0 ? 1 : 0) << 31) | // Sign - (significandOne & 0x7FFFFFFF); // significandOne with MSB inferred - // Exponent stored as an offset to 1023 - returnValue.exponentAndSignificandTwo = ((uint32)(exponent + 1023) << 21) | significandTwo; - - return returnValue; -} - -double decodeDouble_Compact(CompactSerializedDouble value) { - // Expand the exponent and the parts of the significand - int exponent = (int)(value.exponentAndSignificandTwo >> 21) - 1023; - double expandedsignificandOne = (double)(0x80000000 /* Inferred MSB */ | (value.signAndSignificandOne & 0x7FFFFFFF)); - double expandedsignificandTwo = (double)(value.exponentAndSignificandTwo & 0x1FFFFF); - - // Deflate the significand - double shiftedsignificand = ldexp(expandedsignificandTwo, -21); - double significand = ldexp(expandedsignificandOne + shiftedsignificand, -32); - - // Re-calculate the actual double - double returnValue = ldexp(significand, exponent); - - // Check the sign bit and return - return ((value.signAndSignificandOne & 0x80000000) == 0x80000000) ? -returnValue : returnValue; -} - -#endif - } // End of namespace Sword25 diff --git a/engines/sword25/util/double_serialization.h b/engines/sword25/util/double_serialization.h index a910a66f20..af58d03c17 100644 --- a/engines/sword25/util/double_serialization.h +++ b/engines/sword25/util/double_serialization.h @@ -56,43 +56,6 @@ SerializedDouble encodeDouble(double value); */ double decodeDouble(SerializedDouble value); -#if 0 -/** - * Encodes a double as a uint64 - * - * Does NOT support denormalized numbers. Does NOT support NaN, or Inf - * - * @param value The value to encode - * @return The encoded value - */ -uint64 encodeDouble_64(double value); -/** - * Decodes a previously encoded double - * - * @param value The value to decode - * @return The decoded value - */ -double decodeDouble_64(uint64 value); - -/** - * Encodes a double as two uint32 - * - * Does NOT support denormalized numbers. Does NOT support NaN, or Inf - * - * @param value The value to encode - * @return The encoded value - */ -CompactSerializedDouble encodeDouble_Compact(double value); -/** - * Decodes a previously encoded double - * - * @param value The value to decode - * @return The decoded value - */ -double decodeDouble_Compact(CompactSerializedDouble value); - -#endif - } // End of namespace Sword25 #endif |