Вопрос

I have a 32-bit hex value, for example 04FA4FA4 and I want to know how to convert it to BAMS in the form of a double. An example in any language would work fine, I am only concerned about learning the algorithm or formula to make the conversion. I know how to convert to BAMS when I have a form like, 000:00.0000 but I can't figure out how to make the conversion from Hex.

Это было полезно?

Решение

This link is the easiest to understand resource I found. The algorithm is simple:

(decimal hex value) * 180 / 2^(n-1)       //where n is the number of bits

The example in the reference is,

0000 0000 1010 0110
 0    0    A    6
166 * 180 * 2^−15 = 0.9118 degrees

The code for this algorithm is so simple, I don't think I need to enumerate it here. Let me know, if someone feels this is incorrect.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top