Home >Common Problem >What does the q format do?

What does the q format do?

(*-*)浩
(*-*)浩Original
2020-01-09 11:50:013536browse

What does the q format do?

The representation of signed numbers, machine numbers (binary values ​​that appear in computers) have three characteristics, unsigned or converted to numerical values, there is no such information as 10101 , but represented by 010101. (Recommended learning: phpstorm)

only represents a simple integer or decimal. The position of the decimal point is preset at a certain position and rarely changes. Its length is limited by computer hardware. It cannot grow indefinitely.

Q format is to magnify a decimal several times and then use an integer to represent the decimal.

Unsigned number: When the values ​​involved in the operation are not negative and the result of the operation is not negative, all characters can represent the value. This type of unsigned number is called an unsigned number. (such as memory storage address), signed number: a certain number in the value represents the sign, usually the highest bit is used as the sign bit, 0 represents positive, 1 represents negative.

True value: The value represented by a signed number. For example: the value represented by 110 is -2 instead of 6. For signed numbers, the size of the number can be obtained by removing the sign bit. During operation, Its sign bit can participate in operations.

But when adding and subtracting, it must be separated before the operation can be performed. Sometimes, it is also necessary to determine which signed number has a larger true value in order to determine the sign of the result. In order to achieve these functions, the circuit design is quite complex.

So many computer systems do not directly use signed numbers, but use the 1's complement or 2's complement representation of signed numbers as the encoding system

Sine Pulse Width Modulation (SPWM) The control method is converted into variable amplitude and frequency V/F control by a Q format multiplier, which is used as the input signal of its single-phase induction motor. By controlling the size of the duty cycle, the effect of changing the voltage relative to the frequency is achieved.

Operations in Q format

1> Fixed-point addition and subtraction: must be converted into the same Q format to add and subtract

2> Fixed-point multiplication: The multiplication of data in different Q formats is equivalent to the addition of Q values

3> Fixed-point division: The division of data in different Q formats is equivalent to the subtraction of Q values

4> Fixed-point left shift : Left shift is equivalent to Q value increasing

5> Fixed point right shift: Right shift is equivalent to Q decrease

Application format of Q format

Actual In applications, most floating-point operations have both an integer part and a decimal part. Therefore, it is necessary to choose an appropriate scaling format to better handle the operation. Generally, the following two methods are used:

1> Use moderate scaling when using it, which can represent a certain integer reset or a decimal reset. For example, for the 32-bit system of 2812, use the Q15 format, which can represent Data in the range -65536.0~65535.999969482.

2> All decimals are used, so that multiplication between decimals is always a decimal and will never overflow. Take a limit maximum value (preferably using 2 to the nth power) and convert it into a decimal of x/Max (if Max is 2 to the nth power, you can use shifting instead of division).

The above is the detailed content of What does the q format do?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Is wps on the market?Next article:Is wps on the market?