Frequency conversion issue

An issue already exists in MSFS 2020 but is still not fixed in MSFS2024.
The conversion from Hz to MHz is not correct.
Reproduced with this code:
let zut1 = SimVar.GetSimVarValue(“NAV STANDBY FREQUENCY:” + this.navIndex, “MHz”);
let zut2 = SimVar.GetSimVarValue(“NAV STANDBY FREQUENCY:” + this.navIndex, “Hz”);

zut1 returns 109.8999999999
zut2 returns 109900000

There is the same issue in the garminsdk Fms.setLocFrequency function.

I have replaced the line

SimVar.SetSimVarValue(“K:NAV${radioIndex}_STBY_SET_HZ”, “Hz”, approachReferenceFac.freqMHz * 1000000);

With

SimVar.SetSimVarValue(“K:NAV${radioIndex}_STBY_SET_HZ”, “Hz”, Math.round(approachReferenceFac.freqMHz * 100 ) * 10000);

To fix the issue

Hello,

This is not an issue on the sim end, this is simply a difficult to represent number in JS floating point. You’ll note that this does not occur in SimVar Watcher or if you make an equivalent call in WASM/SimConnect.

Thanks,
Matt

Thanks Matt for your answer.
For sure I’m aware this is a js thing.
I just wanted to indicate how we fixed the problem and that the solution could be reported in the framework code.