Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MavLinkParam: Fix error when float param value is larger than decimal.MaxValue #3275

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions ExtLibs/Mavlink/MAVLinkParam.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,18 @@ public double GetValue()
0.8
(double)item.float_value
0.800000011920929
*/
return Math.Round((double)float_value, 7);
*/ {
//In case of very large numbers, decimal conversion could fail. In that case fall back to straight double conversion
try
{
return (double)(decimal)float_value;

}
catch
{
return Math.Round((double)float_value, 7);
}
}
}

throw new FormatException("invalid type");
Expand Down
Loading