摘要 |
PURPOSE: A method for converting binary coded decimal code is provided to minimize a conversion processing time. CONSTITUTION: In a method for converting binary coded decimal(BCD) code, variables(N,D) are initialized with 'Nmax' and '0', respectively(110). a value(BN) is subtracted from a variable(A) to convert, and a subtracted value is allotted to the variable(A). '1' is added to the variable(D) indicating a subtraction number(120). The variable(A) is compared with '0' in order to checks whether the variable(A) is a positive number(130). If the variable(A) is a negative number, a BCD code corresponding to the variable(D) is converted into a BCD code of a corresponding position(160). If the variable(A) is a positive number, there is checked whether the variable value(D) is '8'(140). If so, a BCD code corresponding to '9' is converted into a BCD code of a corresponding position, and the value(BN) is subtracted from the variable(A) to allot the subtracted value to the variable(A)(150). There is checked whether the variable value(N) is '0'(170). If not, '1' is subtracted from the variable value(N). The subtracted value is allotted to the variable(N), and '0' is allotted to the variable(D)(180). If the variable(N) is '0', a BCD code corresponding to a most significant bit(MSB) value of the variable(A) is converted into a BCD code of a corresponding position(190).
|