Jump to content
The simFlight Network Forums

[FS9][FSUIPC3.999] Fuel weight


Recommended Posts

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 isimage.png.045dd2dc406bde4acaa926a49e23448c.png
 

Which type should I use to work in correctly?

Thank you!

Link to comment
Share on other sites

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

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.