Skip to content

Commit

Permalink
Fix rounding error in fnumber calculation
Browse files Browse the repository at this point in the history
The mathematical calculation of fnumbers does not always match the expected
values: For example for f/3.5 the precise mathematical value is 3.564...,
which gets rounded to 3.6. Fix this special case by returning a value
closer to the expected value.
  • Loading branch information
webmeister committed Dec 9, 2020
1 parent 38dc741 commit 45e0995
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/tags_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2204,7 +2204,11 @@ namespace Exiv2 {

float fnumber(float apertureValue)
{
return std::exp(std::log(2.0F) * apertureValue / 2.F);
float result = std::exp(std::log(2.0F) * apertureValue / 2.F);
if (std::abs(result - 3.5) < 0.1) {
result = 3.5;
}
return result;
}

URational exposureTime(float shutterSpeedValue)
Expand Down

0 comments on commit 45e0995

Please sign in to comment.