ztajti Posted May 26, 2020 Report Share Posted May 26, 2020 Hi! I try read the 0x0AF4 offset (Fuel weight as pounds per gallon; size: 2) and the simulator write, the fuel weight is 6.7 Lbs/Gal, the Client read in 6 Lbs/Gal. It's my code: Offset<double> fuelWeight = new Offset<double>("fuel", 0x0AF4); How I can read the real weight value in double/float/decimal? The double result is Which type should I use to work in correctly? Thank you! Link to comment Share on other sites More sharing options...
Pete Dowson Posted May 26, 2020 Report Share Posted May 26, 2020 14 hours ago, ztajti said: I try read the 0x0AF4 offset (Fuel weight as pounds per gallon; size: 2) and the simulator write, the fuel weight is 6.7 Lbs/Gal, the Client read in 6 Lbs/Gal. It's not "pounds per gallon", but punds per gallon * 256. The * means "multiplied by". If you are getting 6 you are ignoring the fraction! 6.7 would be 1715. 14 hours ago, ztajti said: Which type should I use to work in correctly? It's a 2 byte integer, so a 16-bit value. in C is would be a "short", or in Windows terminology, a "WORD". After you read it, if you want it as a floating point value, divide it by 256.0. Please do read the details in the offsets list more carefully. Where they are floating point they are explicitly listed as such -- as "double" (64-bit = 8 bytes), or "float" (32-bits = 4 bytes). Pete Link to comment Share on other sites More sharing options...
ztajti Posted May 26, 2020 Author Report Share Posted May 26, 2020 Thank you for help and sorry my bad english. Tomorrow I update my post, success or not. Have nice night! Link to comment Share on other sites More sharing options...
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