6 kyu

Binary Coded Decimal

73 of 817chipit24

Description:

Convert a number to a binary coded decimal (BCD).

You can assume input will always be an integer. If it is a negative number then simply place a minus sign in front of the output string. Output will be a string with each digit of the input represented as 4 bits (0 padded) with a space between each set of 4 bits.

Ex.

n =  10 -> "0001 0000"
n = -10 -> "-0001 0000"
Algorithms

More By Author:

Check out these other kata created by chipit24

Stats:

CreatedApr 6, 2015
PublishedApr 6, 2015
Warriors Trained1525
Total Skips74
Total Code Submissions3019
Total Times Completed817
Ruby Completions73
JavaScript Completions371
Python Completions397
Julia Completions6
Total Stars18
% of votes with a positive feedback rating90% of 187
Total "Very Satisfied" Votes155
Total "Somewhat Satisfied" Votes27
Total "Not Satisfied" Votes5
Total Rank Assessments21
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • chipit24 Avatar
  • jhoffner Avatar
  • ZozoFouchtra Avatar
  • cliffstamp Avatar
  • stellartux Avatar
  • trashy_incel Avatar
  • mauro-1 Avatar
  • dfhwze Avatar
  • Just4FunCoder Avatar
Ad