Jump to content
The simFlight Network Forums

Fuel Load and Calculation

Recommended Posts

Dear Pete and all

i have a problem i want to share maybe somebody will sign me true way, i want to load fuel on my program and im following this

for read..

capCenter = ((Int32)getCCenter.Value); for capacty reading

LevCenter = ((double)getLevCenter.Value * 100 / (128 * 65536)); for level reading

GalCenter = capCenter * LevCenter / 100; for gallon result

gallonresult * 2.72 = kg result

i thing this read mentallity is correct is here have any problem please tell me.. so now i know this is my kg result if i want to set fuel that tank im using this..

before i must to convert kg to gallon

400 kg / 2.72 = 147 gallon after i must to convert this result to fs language im using this function.

capcenter capacity is 2130 gallon

public double FuelConvert(double dGalon, Int32 iCap)


double iBur = dGalon / 100 * (128 * 65536);

double ioff = iBur * 100 / (128 * 65536) / iCap * 100;

return Math.Round(ioff / 100 * (128 * 65536));


so after this function i have one result is this 578932 and im writting this result on getLevCenter.Value after when i turn to plane and check on fuel 440 kg :(

i dont understand where is my wrong point please help me..

thank you

Link to comment
Share on other sites

Compare these two:

LevCenter = ((double)getLevCenter.Value * 100 / (128 * 65536)); for level reading


double iBur = dGalon / 100 * (128 * 65536);

Don't you see something seriously different which would explain your result?

gallonresult * 2.72 = kg result

Rather than assume a fixed gallon <> kg relationship you should really use the fuel weight value provided at offset 0AF4. Capacity varies with air pressure. You should use the 0AF4 value then convert pounds to kg.

double ioff = iBur * 100 / (128 * 65536) / iCap * 100;

I think you should use more paretheses here. What is being divided by and multiplied by what? I've been a programmer for 46 years and I couldn't swear what the compiler would do with that.

return Math.Round(ioff / 100 * (128 * 65536));

That looks wrong too.

I think you just need to be more careful with your placing of * and / operators, and do use parentheses ( ) to make things clear and explicit.



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • 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.