Jump to content
The simFlight Network Forums

FSUIPC Heading Value

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 comment
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 comment
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 comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 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.