#include <iostream>
#include <cstdint>
using namespace std;
// Compile-time ADC scale computation using integer truncation
constexpr int32_t computeScale(int32_t maxAdc, int32_t maxVoltage_mV) {
// Convert millivolts to microvolts, then divide by ADC resolution
// (3300 * 1000) / 4095 = 805.86... -> truncated to 805
return (maxVoltage_mV * 1000) / maxAdc;
}
// Compile-time microvolts-per-count scale factor
constexpr int32_t SCALE_UV = computeScale(4095, 3300);
int main() {
int32_t x;
if (!(cin >> x)) return 0;
// Runtime ADC-to-voltage conversion
// Max result: 4095 * 805 = 3,296,475 (fits in int32_t)
int32_t voltage_uv = x * SCALE_UV;
cout << voltage_uv;
return 0;
}
Expected Output
0