Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Conversion Reversal

Featured Replies

Does anybody know how to reverse the following formula. Basically, I want to undo this conversion. It's in this C++ speak that I don't understand. If anyone can do this, I'll probably then ask for the XML equivalent reversal. If I get this to work, I'll then share the info. NOTE, I have added a space after the 8 to stop a smiley from showing Conversion: Y = 100 * (1000000 + ((x >> 20) & 0xF)*100000) + ((x >> 16) & 0xF)*10000) + ((x >> 12) & 0xF)*1000) + ((x >> 8 ) & 0xF)*100) + ((x >> 4) & 0xF)*10) + ((x) & 0xF))) cheers, nick

Hi,You can't reverse it as there is an AND operator - the result would be ambiguous.e.g.:11reversed could be:00 && 11-- or --10 && 01That's the problem. :( You could start branching into probability of which would be the most likely answer, but I think that is way beyond the scope of FS.Best regards,Vulcan.

I replied to this in another forum:It isn't syntatically correct - the numbers of opening and closing brackets aren't equal.Ignoring that and assuming x is unsigned long or a DWORD, it appears to extract packed BCD(?) digits from the lower nibbles (4 bits) of x and build a positive integer in the range 100 - 200 million and assign it to Y. Although it is possible reverse the expression to calculate the packed BCD value of (Y/100) - 1000000 and put it in the lower 20 bits of x, it isn't possible to determine what the remaining upper bits of x should be set to from the information available.The ANDing has nothing do with ambiguity, given that 0xF sets all 4 bits (1111). ((x >> 20) & 0xF), for example, shifts right by 20 bits then extracts the lower 4 bits unambiguously.Anyway, the ANDing is bitwise (&) not logical (&&) and the examples you give both AND to 00 not 11.00 & 11 = 0010 & 01 = 00

Gerry Howard

  • Author

Thanks guys, I'll knock it on the head,cheers,nick

it seems to be BCD convertion. Given the numeric ranges, it looks like frequency packed in BCD converted to its numeral form.For example: say frequency is 136.50 I would assume from your code it would be BCD packed in the following way (shown in hexadecimal)0x00365000This is a typical 16.16 fix point format (the 2 MSB are integer frequency and the 2 LSB are fractional frequency)The code then extract each individual BCD digit (1 then 3 then 6 etc...)Y = 100 * (10000000 + (3 * 100000) + (6 * 10000) + (5 * 1000) + (0 * 100) + (0 * 10) + 0)this would give: 100 * 1365000 = 136500000It is often used the way around:(1.0 / 1000.0) * 1365000 = 136.5Hope this helps!

  • Author

Many thanks. Your logic is spot-on. It takes a frequency and then applies the conversion (but shouldn't have done). I think it converts the frequecy to a BCD number.If I understand this properly, the proper frequency digits are recognisable in the result.I know that, say, a frequency of 113.90 becomes 230604000.Can you shed any more light on this. If your thinking is correct, how would you convert the number back to a frequency?Cheers and thanks for the help,nick

Hi,Would be interesting!May be finally we could use: (@c:FlightPlanWaypointFrequency...?Jan"Beatus ille qui procul negotiis..."

Jan

 

 

 

"Beatus ille qui procul negotiis..."

  • Author

Yes correct. BTW, this variable is not used in the GPS and so is not supported by MSFS.cheers,nick

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.