[an error occurred while processing this directive]
С полмесяца назад проскакивало в comp.arch.embedded
(«Телесистемы»: Конференция «Микроконтроллеры и их применение»)

миниатюрный аудио-видеорекордер mAVR

Отправлено Сергей Борщ 06 декабря 2002 г. 20:26
В ответ на: Ответ: отправлено Elektronik 06 декабря 2002 г. 14:50

дискуссия по поводу подобных рассчетов. Т.е. что в двоичном виде с десятичными дробями работать неудобно, а часто и невозможно. Была ссылка на интересную статью:
The problem is that binary floating point can't exactly represent decimal fractions while BCD FP can. In financial systems that's important as the follwing document explains (and which answers my question):
http://www.boic.com/b1mnum.pdf

И еще упомянули:
excess-3 coding is a decimal mechanism, and much more convenient for display, calculation, etc. than BCD.

> Can you give some small example(s) ?
[pre]
Digit BCD coding Excess 3 coding
0 0000 0011
1 0001 0100
2 0010 0101
3 0011 0110
4 0100 0111
5 0101 1000
6 0110 1001
7 0111 1010
8 1000 1011
9 1001 1100
[/pre]
Note that the 9's complement is the bit complement in X3. Adding is done by binary addition and add/subtract 3 depending on carry out, no special tests. Carries are the natural binary carry. To display a negative value, complement all the bits. Detection of 5 or over for rounding is a single bit.

The best (cheapest) decimal arithmetic system is probably 9's complement built around a subtractor (to add, bit complement and subtract). This can ensure that the negative form of zero never arises, and simplifies the logic again.

Может это поможет

Составить ответ  |||  Конференция  |||  Архив

Ответы



Перейти к списку ответов  |||  Конференция  |||  Архив  |||  Главная страница  |||  Содержание  |||  Без кадра

E-mail: info@telesys.ru