From ae4fa704a169e118cf1ef9d76f83c6ee7ca1a47f Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sat, 16 Nov 2024 16:53:57 -0800 Subject: [PATCH] rewrite std::exp to use std::pow Slightly more readable. Signed-off-by: Rosen Penev --- src/canonmn_int.cpp | 4 ++-- src/nikonmn_int.cpp | 2 +- src/tags_int.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/canonmn_int.cpp b/src/canonmn_int.cpp index f9d7b5b64b..01db3baf04 100644 --- a/src/canonmn_int.cpp +++ b/src/canonmn_int.cpp @@ -3053,7 +3053,7 @@ std::ostream& CanonMakerNote::printLe0x0000(std::ostream& os, const Value& value std::ostream& CanonMakerNote::printSi0x0001(std::ostream& os, const Value& value, const ExifData*) { std::ios::fmtflags f(os.flags()); if (value.typeId() == unsignedShort && value.count() > 0) { - os << std::exp(canonEv(value.toInt64()) / 32 * std::log(2.0F)) * 100.0F; + os << std::pow(2.0F, canonEv(value.toInt64()) / 32) * 100.0F; } os.flags(f); return os; @@ -3063,7 +3063,7 @@ std::ostream& CanonMakerNote::printSi0x0002(std::ostream& os, const Value& value std::ios::fmtflags f(os.flags()); if (value.typeId() == unsignedShort && value.count() > 0) { // Ported from Exiftool by Will Stokes - os << std::exp(canonEv(value.toInt64()) * std::log(2.0F)) * 100.0F / 32.0F; + os << std::pow(2.0F, canonEv(value.toInt64())) * 100.0F / 32.0F; } os.flags(f); return os; diff --git a/src/nikonmn_int.cpp b/src/nikonmn_int.cpp index d7db7bcd91..4f1e559797 100644 --- a/src/nikonmn_int.cpp +++ b/src/nikonmn_int.cpp @@ -1759,7 +1759,7 @@ const TagInfo* Nikon3MakerNote::tagListLd4() { } std::ostream& Nikon3MakerNote::printIiIso(std::ostream& os, const Value& value, const ExifData*) { - auto v = std::lround(100.0 * std::exp((value.toInt64() / 12.0 - 5) * std::log(2.0))); + auto v = std::lround(100.0 * std::pow(2.0, value.toInt64() / 12.0 - 5)); return os << v; } diff --git a/src/tags_int.cpp b/src/tags_int.cpp index f0228dc323..f71959c11e 100644 --- a/src/tags_int.cpp +++ b/src/tags_int.cpp @@ -2593,7 +2593,7 @@ std::ostream& printBitmask(std::ostream& os, const Value& value, const ExifData* } float fnumber(float apertureValue) { - float result = std::exp(std::log(2.0F) * apertureValue / 2.F); + float result = std::pow(2.0F, apertureValue / 2.F); if (std::abs(result - 3.5) < 0.1) { result = 3.5; } @@ -2602,7 +2602,7 @@ float fnumber(float apertureValue) { URational exposureTime(float shutterSpeedValue) { URational ur(1, 1); - const double tmp = std::exp(std::log(2.0) * static_cast(shutterSpeedValue)); + const double tmp = std::pow(2.0, shutterSpeedValue); if (tmp > 1) { const double x = std::round(tmp); // Check that x is within the range of a uint32_t before casting.