sniperfull Posted July 17, 2017 Report Posted July 17, 2017 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" & "°")
Paul Henty Posted July 17, 2017 Report Posted July 17, 2017 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. Paul
sniperfull Posted July 17, 2017 Author Report Posted July 17, 2017 What about the HDG going over 360 Degrees?
Pete Dowson Posted July 17, 2017 Report Posted July 17, 2017 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. Pete
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now