Difference between revisions of "Variables - Formats - Encoding - Binary"
m |
m (Spellung and line-spaced for clarity) |
||
Line 12: | Line 12: | ||
For passing info to gauges, or into missions via SimConnect applets. | For passing info to gauges, or into missions via SimConnect applets. | ||
+ | |||
== Binary-Encoding == | == Binary-Encoding == | ||
Line 32: | Line 33: | ||
<br> | <br> | ||
Your code should not include those characters. | Your code should not include those characters. | ||
+ | |||
== Binary-Coded Decimal (BCD) == | == Binary-Coded Decimal (BCD) == | ||
Line 40: | Line 42: | ||
The implementation used in FS is actually "Packed BCD", | The implementation used in FS is actually "Packed BCD", | ||
where one BCD digit is stored in each half byte, (aka nibble). | where one BCD digit is stored in each half byte, (aka nibble). | ||
+ | |||
=== 1 BYTE === | === 1 BYTE === | ||
Line 54: | Line 57: | ||
<br> | <br> | ||
One BCD digit is stored in each half byte, (aka nibble). | One BCD digit is stored in each half byte, (aka nibble). | ||
+ | |||
=== Storage Types === | === Storage Types === | ||
Line 61: | Line 65: | ||
<br> | <br> | ||
typedef VAR32 BCD32, *PBCD32, **PPBCD32; // 8-digit BCD number (00000000-99999999) | typedef VAR32 BCD32, *PBCD32, **PPBCD32; // 8-digit BCD number (00000000-99999999) | ||
+ | |||
=== BCD16 - 2 BYTES === | === BCD16 - 2 BYTES === | ||
Line 81: | Line 86: | ||
<br> | <br> | ||
FS example required | FS example required | ||
+ | |||
==== Note - ==== | ==== Note - ==== | ||
Line 87: | Line 93: | ||
Since the highest order digit in the instrument (gauge) is always 1 (one), | Since the highest order digit in the instrument (gauge) is always 1 (one), | ||
<br> | <br> | ||
− | it is not recorded in the BCD representation to | + | it is not recorded in the BCD representation to save space. (now only 4 digits have to be stored) |
e.g. | e.g. | ||
Line 96: | Line 102: | ||
<br> | <br> | ||
so the recorded BCD is 3625 | so the recorded BCD is 3625 | ||
+ | |||
=== BCD32 - 4 BYTES === | === BCD32 - 4 BYTES === | ||
Line 118: | Line 125: | ||
<br> | <br> | ||
FS example required | FS example required | ||
+ | |||
== Binary-Coded Octal (BCO) == | == Binary-Coded Octal (BCO) == | ||
Equivalent for Octal required. | Equivalent for Octal required. | ||
+ | |||
== Related == | == Related == |
Revision as of 16:40, 9 August 2011
This page is a work-in-progress. Generic message - Please note some detail may possibly be missing or incorrect. |
Placeholder for Variables - Formats - Encoding - Binary related info.
For passing info to gauges, or into missions via SimConnect applets.
Contents
Binary-Encoding
In a fixed-width binary code, each letter, digit, or other character, is represented by a sequence of bits of the same length,
usually indicated in code tables by the octal, decimal or hexadecimal notation for the value of that sequence of bits interpreted as a binary number.
i.e. A method of coding data, as sequences of characters.
Binary-coded decimal, (BCD),is a method of storing individual decimal based characters.
Binary-coded octal, (BCO), is the octal equivalent.
Example Legibility
Requires checking -
For legibility purposes only, the examples below include spaces, dots, hyphens, etc. as seperators.
Your code should not include those characters.
Binary-Coded Decimal (BCD)
Used in - ???
A method of storing individual digits for 'easy' manipulation.
The implementation used in FS is actually "Packed BCD",
where one BCD digit is stored in each half byte, (aka nibble).
1 BYTE
Just for explaining the principle.
These are the BITs in a 8 bit number with their order value for a BCD encoded number:
8 4 2 1 . 8 4 2 1
Example -
0001-0111 is 1-7 which is 1x10 + 7x1 = 17
One BCD digit is stored in each half byte, (aka nibble).
Storage Types
BCD 16 or 32 defines the storage type -
typedef VAR16 BCD16, *PBCD16, **PPBCD16; // 4-digit BCD number (0000-9999)
typedef VAR32 BCD32, *PBCD32, **PPBCD32; // 8-digit BCD number (00000000-99999999)
BCD16 - 2 BYTES
Used in - ???
These are the BITs in a 16 bit number with their order value for a BCD encoded number:
8 4 2 1 . 8 4 2 1 . 8 4 2 1 . 8 4 2 1
This is 2 bytes and can store a 4 digit BDC16 encoded number,
with one BCD digit stored in each half byte, (aka nibble).
Example -
0011-0110 0010-0101 is 3-6 2-5 which is 3x100 + 6x10 + 2x1 + 5x0.1 = 362.5
Useage -
FS example required
Note -
For COM and NAV frequencies there's a legacy related matter -
Since the highest order digit in the instrument (gauge) is always 1 (one),
it is not recorded in the BCD representation to save space. (now only 4 digits have to be stored)
e.g.
For a frequency of 136.25
1 is assumed
so the recorded BCD is 3625
BCD32 - 4 BYTES
Used in - ???
These are the BITs in a 32 bit number with their order value for a BCD encoded number:
8 4 2 1 . 8 4 2 1 . 8 4 2 1 . 8 4 2 1 . 8 4 2 1 . 8 4 2 1 . 8 4 2 1 . 8 4 2 1
BCD32 is 4 bytes for an 8 digit BCD encoded number,
again with one BCD digit stored in each half byte, (aka nibble).
Example -
THIS EXAMPLE NEEDS CHECKING/CORRECTING
0001-0011 1000-0100 0101-0000 0000-0000 is 1-3 8-4 5-0 0-0 which is 1x1000 + 3x100 + 8x10 + 4x1 + 5x0.1 = 1384.5
Useage -
FS example required
Binary-Coded Octal (BCO)
Equivalent for Octal required.
Related
Hex-Decimal-Binary online converter at - http://flor.nl/dec2hex.html