The simFlight Network Forums

Multiplying by 65536

Recommended Posts

For the autopilot, the altitude value in meters  (and also the heading info in degrees/360) are both multiplied by 65536 (2 to the 16th power). Is this to eliminate fractional values and facilitate rounding somehow?

I'm trying to figure out how the individual altitude digits displayed on the autopilot are actually represented in the 4 byte offset, ie, can the digits be mapped to hex characters in each byte of the offset similar to how the frequency digits for a Com radio are represented in the COM offset?

Thx,

Al

Share on other sites

For the autopilot, the altitude value in meters  (and also the heading info in degrees/360) are both multiplied by 65536 (2 to the 16th power). Is this to eliminate fractional values and facilitate rounding somehow?

I'm trying to figure out how the individual altitude digits displayed on the autopilot are actually represented in the 4 byte offset, ie, can the digits be mapped to hex characters in each byte of the offset similar to how the frequency digits for a Com radio are represented in the COM offset?

Values in FS are represented in units which afford the best precision in the space avaiallbe. For an angle from 0-360 this is done in a 16 bit value by making 65536 represent 360. (360 is the same as 0). So 65535 would be just 1 1/65535th of a degree less than 360. For a 32-bit value the same applies, but 65536*65536 = 360. And so on.

The altitude in 0570 is a 64-bit value, in metres and fractional metres, as documented. The top 32 bits are metres, the lower 32 bits are 1/(65536*65536)ths of a metre. Just consider the whole 64 bits as a number with the binary point in the middle, 32 bits of integer, 32 bits of fraction.

There is no hex representation of any values other than radios and transponders. They are all actual numbers. As documented in fact.

Use FSInterrogate which can display these things in all manner of ways. Perhaps you might understand better then?

Regards

Pete

Share on other sites

The altitude in 0570 is a 64-bit value, in metres and fractional metres, as documented. The top 32 bits are metres, the lower 32 bits are 1/(65536*65536)ths of a metre. Just consider the whole 64 bits as a number with the binary point in the middle, 32 bits of integer, 32 bits of fraction.

I was looking at working with the autopilot altitude value in 07D4. It uses only 32 bits total, maybe because only values to the nearest 100 ft are displayed?

Thanks very much for the info.

Al

Share on other sites

I was looking at working with the autopilot altitude value in 07D4. It uses only 32 bits total, maybe because only values to the nearest 100 ft are displayed?

Maybe, but it still uses the same principle, 16 top bits for whole metres, lower 16 bits for fractions -- 1/65536ths. These sort of  representations date back as far as FS98 days and pervade FS. Nowadays they are more usually held internally as 32 or 64 bit floating point numbers, but FSUIPC has to convert them to the original FS98 format for compatibilty. The whole point of FSUIPC was to present a compatible interface across all versions, FS98-FS2000-FS2002-FS2004-FSX, and even CFS1 and CFS2.

Regards

Pete

Create an account

Register a new account