[Bug]: human_to_eng() parses MHz incorrectly #12
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
human_to_eng()can interpret values such as1.5 MHzincorrectly because the old strip order removeshzbefore suffix matching.Current code
Why this is a bug
With the old logic,
1.5 MHzbecomes1.5 mbefore suffix evaluation.That can result in
mbeing interpreted as milli instead ofMHzbeing interpreted as mega, which sends a completely wrong numeric value to the instrument.Example
1.5 MHzshould become:With the old parser it could be interpreted as milli-scale instead.
Fix approach
Replace the strip-and-guess logic with a regex-based parser that reads numeric value and suffix in one pass, using longest suffix match first.
This avoids
mhzcollapsing intomand makes unit handling much more robust.Status
Local fix already implemented in the current v0.2 working copy.
Still needs commit, push, and hardware verification before closing.
human_to_eng() parses MHz incorrectlyto [Bug]: human_to_eng() parses MHz incorrectly