numeri formats : decimal > 1.23 format
how to convert decimal values (ex: 6.5) in digital (format 1.23) ?
how to convert decimal values (ex: 6.5) in digital (format 1.23) ?
...I had to convert values for an EQ coefficient for Analog Devices AD1954 (or AD1953), SigmaDSP.
i have example:
ex: 2.20 format
100000000000000000000 = -2.0
110000000000000000000 = -1.0
010000000000000000000 = 1.0
but for othe decimal values ?
i have example:
ex: 2.20 format
100000000000000000000 = -2.0
110000000000000000000 = -1.0
010000000000000000000 = 1.0
but for othe decimal values ?
you have to think of things below the decimal point as still being in powers multiples of 2 to the power of whatever.
i.e. the first binary digit after your zero digit will be 1/2, then 1/4 etc. So, if you wanted to store 1.25 in your 1,23 scheem 10100000... (with the fist one bing equal to 2^0, then the second one in the sequence being 2^[-2])
If you think about it, it is just the same as in a decimal system, but with base two rather than ten (0.1 =10^[-1], and 0.5 = 2^[-1])
i.e. the first binary digit after your zero digit will be 1/2, then 1/4 etc. So, if you wanted to store 1.25 in your 1,23 scheem 10100000... (with the fist one bing equal to 2^0, then the second one in the sequence being 2^[-2])
If you think about it, it is just the same as in a decimal system, but with base two rather than ten (0.1 =10^[-1], and 0.5 = 2^[-1])
It is not such an easy question if you plan to do signal processing with it.
The things to consider is the tradeoff between resolution and risc of saturation/wraparound. If you want to do it properly then you need to design for the worst case, i.e. all coefficients and the input to the filter adds up and this will decide the decimal point.
If you want to make it simpler as a rule of thumb you could use the maximum gain of the filter as a way to decide where to put the decimal point and shift it one more step to the right to have headroom for internal nodes in the filter.
Decide where you want to place the decimal point and then the actual conversion sould be straight forward. The thing to remember is that you might not be able to represent the decimal values exactly wherever you place the decimal point. (0.1 is an example)
The things to consider is the tradeoff between resolution and risc of saturation/wraparound. If you want to do it properly then you need to design for the worst case, i.e. all coefficients and the input to the filter adds up and this will decide the decimal point.
If you want to make it simpler as a rule of thumb you could use the maximum gain of the filter as a way to decide where to put the decimal point and shift it one more step to the right to have headroom for internal nodes in the filter.
Decide where you want to place the decimal point and then the actual conversion sould be straight forward. The thing to remember is that you might not be able to represent the decimal values exactly wherever you place the decimal point. (0.1 is an example)
- Status
- Not open for further replies.