Skip to content

Commit bf95347

Browse files
committed
rewrite std::exp to use std::pow
Slightly more readable. Signed-off-by: Rosen Penev <[email protected]>
1 parent 055fa46 commit bf95347

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/canonmn_int.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3053,7 +3053,7 @@ std::ostream& CanonMakerNote::printLe0x0000(std::ostream& os, const Value& value
30533053
std::ostream& CanonMakerNote::printSi0x0001(std::ostream& os, const Value& value, const ExifData*) {
30543054
std::ios::fmtflags f(os.flags());
30553055
if (value.typeId() == unsignedShort && value.count() > 0) {
3056-
os << std::exp(canonEv(value.toInt64()) / 32 * std::log(2.0F)) * 100.0F;
3056+
os << std::pow(2.0F, canonEv(value.toInt64()) / 32) * 100.0F;
30573057
}
30583058
os.flags(f);
30593059
return os;
@@ -3063,7 +3063,7 @@ std::ostream& CanonMakerNote::printSi0x0002(std::ostream& os, const Value& value
30633063
std::ios::fmtflags f(os.flags());
30643064
if (value.typeId() == unsignedShort && value.count() > 0) {
30653065
// Ported from Exiftool by Will Stokes
3066-
os << std::exp(canonEv(value.toInt64()) * std::log(2.0F)) * 100.0F / 32.0F;
3066+
os << std::pow(2.0F, canonEv(value.toInt64())) * 100.0F / 32.0F;
30673067
}
30683068
os.flags(f);
30693069
return os;

src/nikonmn_int.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1759,7 +1759,7 @@ const TagInfo* Nikon3MakerNote::tagListLd4() {
17591759
}
17601760

17611761
std::ostream& Nikon3MakerNote::printIiIso(std::ostream& os, const Value& value, const ExifData*) {
1762-
auto v = std::lround(100.0 * std::exp((value.toInt64() / 12.0 - 5) * std::log(2.0)));
1762+
auto v = std::lround(100.0 * std::pow(2.0, value.toInt64() / 12.0 - 5));
17631763
return os << v;
17641764
}
17651765

src/tags_int.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2593,7 +2593,7 @@ std::ostream& printBitmask(std::ostream& os, const Value& value, const ExifData*
25932593
}
25942594

25952595
float fnumber(float apertureValue) {
2596-
float result = std::exp(std::log(2.0F) * apertureValue / 2.F);
2596+
float result = std::pow(2.0F, apertureValue / 2.F);
25972597
if (std::abs(result - 3.5) < 0.1) {
25982598
result = 3.5;
25992599
}
@@ -2602,7 +2602,7 @@ float fnumber(float apertureValue) {
26022602

26032603
URational exposureTime(float shutterSpeedValue) {
26042604
URational ur(1, 1);
2605-
const double tmp = std::exp(std::log(2.0) * static_cast<double>(shutterSpeedValue));
2605+
const double tmp = std::pow(2.0, shutterSpeedValue);
26062606
if (tmp > 1) {
26072607
const double x = std::round(tmp);
26082608
// Check that x is within the range of a uint32_t before casting.

0 commit comments

Comments
 (0)