Skip to content

Commit

Permalink
rewrite std::exp to use std::pow
Browse files Browse the repository at this point in the history
Slightly more readable.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
  • Loading branch information
neheb committed Nov 18, 2024
1 parent 055fa46 commit bf95347
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/canonmn_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/nikonmn_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions src/tags_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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<double>(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.
Expand Down

0 comments on commit bf95347

Please sign in to comment.