Jump to content
The simFlight Network Forums

Roman Alexeev

new Members
  • Posts

    2
  • Joined

  • Last visited

Roman Alexeev's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Hi Pete! Please help to sort out this issue. This is my sample code in C# reading values from 0570 and 0574 offsets: int altInt = 0; int altFract = 0; public double GetAltitude (ref Fsuipc fsui) { int token = new int(); bool result = new bool(); int dwResult = -1; result = fsui.FSUIPC_Read(0x0574, 4, ref token, ref dwResult); result = fsui.FSUIPC_Process(ref dwResult); result = fsui.FSUIPC_Get(ref token, ref dwResult); altInt = dwResult; result = fsui.FSUIPC_Read(0x0570, 4, ref token, ref dwResult); result = fsui.FSUIPC_Process(ref dwResult); result = fsui.FSUIPC_Get(ref token, ref dwResult); altFract = dwResult; return CalculateNumber(altInt, altFract); } public static double CalculateNumber(int integerPart, int fractionPart) { return integerPart + fractionPart / (Math.Pow(10d, Math.Floor(Math.Log10(fractionPart) + 1))); } This code works fine except that cases when the fractial part is going negative and i receive such an output like this (where the "??????" stands for NaN): -39.2589834903434;176.890642367512;1536.1331560448 -39.2589705535967;176.89063817336;1529.359530496 -39.2589521142119;176.890632849115;1523.1671954432 -39.2589391723849;176.890628650765;1516.1083768832 -39.2589209205589;176.890623346235;???????? -39.2589085795789;176.890619044647;???????? -39.2588956332209;176.890614866274;???????? -39.2588744544625;176.890609329054;???????? -39.2588562583823;176.890605053622;???????? -39.2588435700205;176.890599573182;1479.275316736 -39.2588255948642;176.890595332712;1473.1923350528 -39.2588132538842;176.890590821005;1466.151519232 -39.2587958814971;176.890585272603;???????? -39.2587833990929;176.890580778234;???????? -39.2587573968074;176.890574983868;???????? -39.258744840533;176.890570560876;???????? Please help to sort out!
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.