From 80bd868b84d47bfe68c73af477f4b2e9f404d6a6 Mon Sep 17 00:00:00 2001 From: Andras Schaffer Date: Mon, 15 Jan 2024 11:10:51 +0100 Subject: [PATCH] Fix error when float param value is larger than decimal.MaxValue --- ExtLibs/Mavlink/MAVLinkParam.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ExtLibs/Mavlink/MAVLinkParam.cs b/ExtLibs/Mavlink/MAVLinkParam.cs index 5f1c3962d8..0f25534a37 100644 --- a/ExtLibs/Mavlink/MAVLinkParam.cs +++ b/ExtLibs/Mavlink/MAVLinkParam.cs @@ -128,8 +128,18 @@ public double GetValue() 0.8 (double)item.float_value 0.800000011920929 - */ - return (double)(decimal)float_value; + */ { + //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 (double)float_value; + } + } } throw new FormatException("invalid type");