ziqabo Posted October 11, 2003 Report Posted October 11, 2003 Hi, i have a problem when i read the offset 07CC, i wrote in delphi this lines ff : single; FSUIPC_Read($07cc, 2, @ff, result); FSUIPC_Process(result); label4.Caption := floatToStr((ff/65536)*360); but i get a value that not is de HDG of Autopilot. Thanks.
Pete Dowson Posted October 11, 2003 Report Posted October 11, 2003 ff : single; FSUIPC_Read($07cc, 2, @ff, result); I don't know Delphi -- is "single" a 16-bit unsigned integer, because if it isn't there's your first mistake? The heading at 07CC is! Then, if you divide a 16 bit value by 65536 you are bound to get a fraction and you can't hold fractions in a 16-bit integer. Try copying the value into a floating point variable before you do the conversion. If a Delphi "single" is a 32-bit "float" then you cannot read the 16-bit integer directly into that and expect it to make any sense. Floating point formats are completely different. Regards, Pete
ziqabo Posted October 11, 2003 Author Report Posted October 11, 2003 ff : single; FSUIPC_Read($07cc, 2, @ff, result); I don't know Delphi -- is "single" a 16-bit unsigned integer, because if it isn't there's your first mistake? The heading at 07CC is! Then, if you divide a 16 bit value by 65536 you are bound to get a fraction and you can't hold fractions in a 16-bit integer. Try copying the value into a floating point variable before you do the conversion. If a Delphi "single" is a 32-bit "float" then you cannot read the 16-bit integer directly into that and expect it to make any sense. Floating point formats are completely different. Regards, Pete Roger thanks the unsigne 16 bit is "word" in delphi and now run ok. Thanks.
TweakFS Posted October 11, 2003 Report Posted October 11, 2003 label4.Caption := floatToStr((ff/65536)*360); To remove the decimal places being displayed try this: label4.Caption:=format('%.0f °', [(ff/65536)*360]) Now all you need to do is work out how to pad it out with zero's so you get heading '090' instead of '90' :grin:
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