diff --git a/lib/codeplug.hh b/lib/codeplug.hh index 2f612518..acf931d8 100644 --- a/lib/codeplug.hh +++ b/lib/codeplug.hh @@ -63,13 +63,13 @@ public: /** Implements a simple increment. */ inline Bit operator+ (unsigned int bits) const { unsigned int tmp = 8 * byte + (7-bit) + bits; - return {tmp/8, (7 - bit % 8)}; + return {tmp/8, (7 - (tmp % 8))}; } /** Implements a simple increment. */ inline Bit operator- (unsigned int bits) const { unsigned int tmp = 8 * byte + (7-bit) - bits; - return {tmp/8, (7 - bit % 8)}; + return {tmp/8, (7 - (tmp % 8))}; } }; }; diff --git a/lib/opengd77base_satelliteconfig.cc b/lib/opengd77base_satelliteconfig.cc index 9a7182fb..9b351645 100644 --- a/lib/opengd77base_satelliteconfig.cc +++ b/lib/opengd77base_satelliteconfig.cc @@ -26,7 +26,7 @@ OpenGD77BaseSatelliteConfig::SatelliteElement::clear() { void OpenGD77BaseSatelliteConfig::SatelliteElement::writeDigit(const Offset::Bit &offset, uint8_t digit) { - // Must be bit 0 or 4 (BCD) + // Must be bit 0 or 3 (BCD) if (offset.bit % 4) return; @@ -53,10 +53,7 @@ OpenGD77BaseSatelliteConfig::SatelliteElement::writeInteger(const Offset::Bit &o o += 4*(dec-1); for (int i=dec; i>0; i--, o = o - 4) { - if (value) - writeDigit(offset + o, value % 10); - else - writeDigit(offset + o, 0xb); + writeDigit(offset + o, value % 10); value /= 10; } } @@ -71,11 +68,13 @@ OpenGD77BaseSatelliteConfig::SatelliteElement::writeFractional(const Offset::Bit if (0 == frac) return; - if (sign && (0 > value)) - writeDigit(offset + o, 0xc); - else - writeDigit(offset + o, 0xb); - o += 4; + if (sign) { + if (0 > value) + writeDigit(offset + o, 0xc); + else + writeDigit(offset + o, 0xb); + o += 4; + } value -= int(value); for (unsigned int i=0; i