swift
Loading...
Searching...
No Matches
bcdconversions.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 2013 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#ifndef SWIFT_MISC_SIMULATION_FSCOMMON_BCDCONVERSIONS_H
7#define SWIFT_MISC_SIMULATION_FSCOMMON_BCDCONVERSIONS_H
8
9#include <QtGlobal>
10
11#include "misc/pq/frequency.h"
13
14namespace swift::misc
15{
16 namespace aviation
17 {
18 class CTransponder;
19 }
20 namespace simulation::fscommon
21 {
23 class SWIFT_MISC_EXPORT CBcdConversions
24 {
25 public:
27 static quint32 bcd2Dec(qint32 bcdNum) { return bcd2Dec(static_cast<quint32>(bcdNum)); }
28
30 static quint32 bcd2Dec(quint32 bcdNum) { return hornerScheme(bcdNum, 0x10, 10); }
31
33 static quint32 dec2Bcd(quint32 decNum) { return hornerScheme(decNum, 10, 0x10); }
34
36 static quint32 comFrequencyToBcdHz(const swift::misc::physical_quantities::CFrequency &comFrequency);
37
39 static quint32 transponderCodeToBcd(const swift::misc::aviation::CTransponder &transponder);
40
41 private:
43 CBcdConversions() {} // NOLINT(modernize-use-equals-default)
44
46 static quint32 hornerScheme(quint32 num, quint32 divider, quint32 factor);
47 };
48 } // namespace simulation::fscommon
49} // namespace swift::misc
50
51#endif // SWIFT_MISC_SIMULATION_FSCOMMON_BCDCONVERSIONS_H
static quint32 bcd2Dec(quint32 bcdNum)
BCD -> decimal.
static quint32 bcd2Dec(qint32 bcdNum)
BCD -> decimal.
static quint32 dec2Bcd(quint32 decNum)
Decimal -> BCD.
Free functions in swift::misc.
#define SWIFT_MISC_EXPORT
Export a class or function from the library.