fix: round float params to 6 significant digits on file save#82
Merged
rubenCodeforges merged 1 commit intorubenCodeforges:masterfrom Mar 30, 2026
Merged
Conversation
MAVLink sends 32-bit floats; decoding them into JS 64-bit doubles introduces noise (e.g. 0.18000000715255737 instead of 0.18). Applying toPrecision(6) + parseFloat matches MissionPlanner behaviour and produces clean, human-readable parameter files.
Owner
|
Im gonna get drunk to celebrate the first community PR ! And ill check your pr tomorrow when im back at the HQ. |
Contributor
Author
|
Hey @rubenCodeforges , thanks for the warm welcome! Honored to be the first community PR . No worries on the timeline, totally understand — take your time with the review. I'll be here if you need any changes or have feedback. Looking forward to it! |
Owner
|
Looks good to me , we will probably squeeze it in the Alpha 30 , @evanofficial great job , thank you ! |
Contributor
Author
Thanks! glad to help out, excited to see it land in alpha 30 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #78.
Root cause
MAVLink transmits parameters as 32-bit single-precision floats. When the Electron main process receives them and stores them as JavaScript
number(64-bit double), the conversion introduces floating-point noise:The bug is on this line in
PARAM_SAVE_FILE:p.valueis the raw double with noise.Fix
Add a
formatValuehelper that appliestoPrecision(6)(6 significant digits — the reliable precision of a 32-bit float) thenparseFloatto strip trailing zeros:Before → After examples:
0.180000007152557370.180000007152557370.180.89999997615814210.89999997615814210.90.0040000001899898050.0040000001899898050.0040.50.50.5000Test plan
npx tsc --noEmitpassesnpx eslint .passesI have read and agree to the ArduDeck Contributor License Agreement (CLA.md).