Author |
Topic: Base 13 subtraction (Read 2101 times) |
|
minniekp
Newbie
Gender:
Posts: 3
|
|
Base 13 subtraction
« on: Aug 17th, 2007, 1:59am » |
Quote Modify
|
How do you subtract two numbers in base 13 given below: (A023AC5B) -(129B5321) to the base 13 This was asked in Adobe written test. Thanks
|
|
IP Logged |
|
|
|
inexorable
Full Member
Posts: 211
|
|
Re: Base 13 subtraction
« Reply #1 on: Aug 17th, 2007, 2:54am » |
Quote Modify
|
8A55593A can't it be answered by just doing by hand? the carry will be 13 as its base 13
|
|
IP Logged |
|
|
|
towr
wu::riddles Moderator Uberpuzzler
Some people are average, some are just mean.
Gender:
Posts: 13730
|
|
Re: Base 13 subtraction
« Reply #2 on: Aug 17th, 2007, 3:12am » |
Quote Modify
|
Simple way is to convert both to integers, subtract, and return to base 13. Another way is to turn it into an addition, for the number you want to subtract, change every digit to 13- that digit. Add the two numbers base-13 and ermm, add 1 extra for good measure? And mind the overflow. There's some details to bare in mind (for which I don't have time now); but basically adapt what you'd do for binary.
|
|
IP Logged |
Wikipedia, Google, Mathworld, Integer sequence DB
|
|
|
Grimbal
wu::riddles Moderator Uberpuzzler
Gender:
Posts: 7527
|
|
Re: Base 13 subtraction
« Reply #3 on: Aug 17th, 2007, 5:13am » |
Quote Modify
|
OK, here is how it's done. Remember A=10, B=11, etc. Start from the right. B-1 = A. 5-2 = 3 C-3 = 12-3 = 9 A-5 = 10-5 = 5 so far so good. 3-B = 3-11 = uh... it gets negative so add 13 to 3 and remember the carry 16-11 = 5 2-1(carry)-9 = ... add 13 to 2 = 15, remember carry 15-1-9 = 5 0-1-2 = ... add 13 to 0 = 13, remember carry 13-1-2 = 10 = A A-1-1 = 8 put it together: 8A55593A
|
« Last Edit: Aug 17th, 2007, 7:40am by Grimbal » |
IP Logged |
|
|
|
towr
wu::riddles Moderator Uberpuzzler
Some people are average, some are just mean.
Gender:
Posts: 13730
|
|
Re: Base 13 subtraction
« Reply #4 on: Aug 17th, 2007, 7:17am » |
Quote Modify
|
Here's my approach worked out: A023AC5B -129B5321 --------- (modulo 10000000) A023AC5B +BA3179AB (12's/C's complement -> 129B5321+BA3179AB = CCCCCCCC) + 1 (because CCCCCCCC + 1 = 10000000) --------- 18A55593A --------- mod 10000000 8A55593A
|
|
IP Logged |
Wikipedia, Google, Mathworld, Integer sequence DB
|
|
|
Grimbal
wu::riddles Moderator Uberpuzzler
Gender:
Posts: 7527
|
|
Re: Base 13 subtraction
« Reply #5 on: Aug 17th, 2007, 7:43am » |
Quote Modify
|
Of course, when you add BA3179AB+1, in fact you add BA3179AB.CCC... Because CCCCCCCC.CCC... = 0 (mod 100000000)
|
« Last Edit: Aug 17th, 2007, 7:45am by Grimbal » |
IP Logged |
|
|
|
|