Jump to content
The simFlight Network Forums

Recommended Posts

i've just noticed a "bug" in my program  as the heading value goes above 360 .... and its sometimes in accurate by a couple of degrees  here's my code:


Dim HDG As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&H580) ' aircraft heading

Dim Heading As Double = (HDG.Value * 360 / 65536 * 65536)
            TxtHDG.Text = Heading.ToString("0" & "°")


Link to post
Share on other sites

You should probably declare the offset as UInteger because the value is unsigned (it will never be -20 degrees for example).

Dim HDG As Offset(Of UInteger) = New FSUIPC.Offset(Of UInteger)(&H580) ' aircraft heading

When you say it's inaccurate, what are you comparing it to? This offset gives the True heading, not the magnetic heading shown on the aircraft instruments.


Link to post
Share on other sites
1 hour ago, sniperfull said:

What about the HDG going over 360 Degrees?

The value actually in 0580 cannot ever represent anything over 359.999999 ... degrees. 360 would be zero in any case.

The units in the 32-bit offset 0580 are the actual heading (0-359.9999...) divided by 360 (so it is completely fractional) then multiplied by 4294967296 (the maximum possible unsigned value in 32-bits), so making full use of those 32 bits. Thus the largest value, converted back to degrees, cannot be 360 or anything higher.



Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • 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.