BCD16

Use this forum to discuss technical issues related to the operation of your computer. Graphics, Hardward, Software, settings, etc.
Post Reply
User avatar
kungfuman
Lieutenant Colonel
Lieutenant Colonel
Posts: 845
Joined: 01 Jun 2008, 18:21
Version: FS9
Location: EGGD

BCD16

Post by kungfuman »

Hi folks,

Anyone know how to encode a vhf frequency into the sort of format that an FS9 BGL file would use?

I am lead to believe the following:

Frequencies of the form 1ab.cd MHz are stored as "abcd" in BCD16 format.

So AFAIK, this means that 126.900 MHz would be stored as 0x2690, or

0010 0110 1001 0000

However, the space assigned is a dword, not a word, so will the additional bits just be 16 more zeros on the right?

Also, are frequencies with three decimal places truncated to only 2 d.p. (that being all that is necessary)?

Cheers,

Dan "raised by wolves"
User avatar
VulcanDriver
MAIW Staff
MAIW Staff
Posts: 4575
Joined: 11 Aug 2006, 20:58
Version: FSX
Location: EGHH

Post by VulcanDriver »

:shock:
John

"That is the biggest fool thing we have ever done. The A-bomb will never go off, and I speak as an expert in explosives." - Admiral William Leahy
User avatar
kungfuman
Lieutenant Colonel
Lieutenant Colonel
Posts: 845
Joined: 01 Jun 2008, 18:21
Version: FS9
Location: EGGD

Post by kungfuman »

VulcanDriver wrote::shock:
:lol: :lol: :lol:

Well, this is the tech forum, right?
BASys
Second Lieutenant
Second Lieutenant
Posts: 36
Joined: 12 Aug 2006, 11:58
Version: FSX
Location: EGNL, Barrow-in-Furness, Cumbria, UK
Contact:

Post by BASys »

Hi Folks

kungfuman -
Please see - FSDeveloper - Wiki - Variables - Formats - Encoding - Binary
It's a WIP, but might cover what you're after.

Regarding spaces, dots, hyphens etc.
I think they're only included for ease of reading.
AIUI there should be none, it's just the binary value.
e.g. 0011011000100101

HTH
ATB
Paul
User avatar
kungfuman
Lieutenant Colonel
Lieutenant Colonel
Posts: 845
Joined: 01 Jun 2008, 18:21
Version: FS9
Location: EGGD

Post by kungfuman »

Thanks Paul,

That confirms my understanding about BCD16 :wink:
User avatar
kungfuman
Lieutenant Colonel
Lieutenant Colonel
Posts: 845
Joined: 01 Jun 2008, 18:21
Version: FS9
Location: EGGD

Post by kungfuman »

Not that I expect there to much interest here, but for what it's worth I have found that the frequencies are simply encoded as an int32, the value of which being the frequency in Hz.

If you're doing this for the first time and need more explanation, read on.

To find out what the content of the "int32" would be for 123.45 MHz, take 123.45 and multiply by 1,000,000 (1 million), then convert into the base-16 value (aka hexadecimal, or just hex): 075bb290. This is then easily translated into binary, with each digit representing four "bits" (aka a "nibble"):

Hex -> Binary
0 ----> 0000
7 ----> 0111
5 ----> 0101
b ----> 1011
b ----> 1011
2 ----> 0010
9 ----> 1001
0 ----> 0000

The int32 will store this binary number
0000 0111 0101 1011 1011 0010 1001 0000 (the spaces are used here only for ease of presentation)
by splitting the 32 digits into 4 groups, each one consisting of 8 digits (these digits are the "bits", and the groups are the "bytes"). The first group stored in the int32 (the first byte) is the group representing the least significant part of the number (the 1s, 2s, 4s, 8s, 16s, 32s, 64s and 128s): 10010000
Notice that these are the last 8 digits on the right. The second byte is the next 8 digits to the left of the first byte: 10110010
And so on.

Maybe of help to someone one day, you never know!
User avatar
Garysb
MAIW Developer
MAIW Developer
Posts: 2814
Joined: 11 Aug 2006, 19:33
Version: FSX
Location: Scunthorpe, North Lincolnshire, UK

Post by Garysb »

Kungfuman
Can I suggest therapy ! :lol: :lol: :lol: :lol: :shock:


Cheers


Gary
I believe that every human has a finite number of heart-beats. I don't intend to waste any of mine running around doing exercises.
Buzz Aldrin (1930 -
User avatar
kungfuman
Lieutenant Colonel
Lieutenant Colonel
Posts: 845
Joined: 01 Jun 2008, 18:21
Version: FS9
Location: EGGD

Post by kungfuman »

Can you recommend someone? The NHS just gave me pills...
User avatar
petebramley
MAIW Developer
MAIW Developer
Posts: 1545
Joined: 17 Jun 2007, 16:05
Version: P3D
Location: EGBG

Post by petebramley »

I recommend a large glass of Laphroaig (water to taste). I have found this to be the cure to all ills
:D :D :D :D

Pete
User avatar
VulcanDriver
MAIW Staff
MAIW Staff
Posts: 4575
Joined: 11 Aug 2006, 20:58
Version: FSX
Location: EGHH

Post by VulcanDriver »

kungfuman wrote:
VulcanDriver wrote::shock:
:lol: :lol: :lol:

Well, this is the tech forum, right?
It brought back all the horrors of my IT university course!!
John

"That is the biggest fool thing we have ever done. The A-bomb will never go off, and I speak as an expert in explosives." - Admiral William Leahy
User avatar
kungfuman
Lieutenant Colonel
Lieutenant Colonel
Posts: 845
Joined: 01 Jun 2008, 18:21
Version: FS9
Location: EGGD

Post by kungfuman »

For some reason the little smiley looking plaintively out of the page with shocked eyes had me in stitches. I really do need help!

Probably the best reply I've ever had to a post of mine...
User avatar
ricktk
Captain
Captain
Posts: 254
Joined: 18 Aug 2006, 23:03
Version: P3D
Location: Between KDPA and KARR

Post by ricktk »

All I can say is a Dalwhinnie solved my headache over this thread! It all became clear. (Hic) Well, maybe not, but it did make me feel better. Cheers :D
Rick

"Buttons . . . check. Dials . . . check. Switches . . . check. Little colored lights . . . check."
Post Reply