decimal to bcd fix

This commit is contained in:
lukew3
2020-10-23 13:40:42 -04:00
parent 595e92513a
commit c8815aec75
4 changed files with 111 additions and 108 deletions

View File

@@ -107,3 +107,4 @@ from .quotient_of_power_same_power import *
from .complex_quadratic import *
from .is_leap_year import *
from .minutes_to_hours import *
from .decimal_to_bcd import *

View File

@@ -1,22 +1,23 @@
from .__init__ import *
from .__init__ import *
def DecimalToBCDFunc(maxNumber=10000):
n = random.randint(1000, maxNumber)
x=n
x = n
binstring = ''
bcdstring = ''
while x > 0:
nibble = x % 16
bcdstring = str(nibble) + bcdstring
x >>= 4
problem = "BCD of Decimal Number " + str(n) + " is = "
solution = int(bcdstring)
return problem, solution
decimal_to_bcd = Generator("Decimal to Binary Coded Decimal", 101,
decimal_to_bcd = Generator("Decimal to Binary Coded Decimal", 103,
"Binary Coded Decimal of Decimal n is ", "b",
DecimalToBCDFunc)
##for readme ## | 101 | Decimal to Binary Coded Decimal | Binary Coded Decimal of Decimal 34 is = | 22 | decimal_to_bcd |
# for readme ## | 101 | Decimal to Binary Coded Decimal | Binary Coded Decimal of Decimal 34 is = | 22 | decimal_to_bcd |