Talk:Sum digits of an integer: Difference between revisions

(→‎Output base: 256/16 -> 29/10 not 13/10?)
Line 5:
 
::I don't understand. "SumDigits(0xfe, 10) would return 11 and that SumDigits(254, 16) would return 29." if sumDigits(0xfe, 16) -> 29<sub>10</sub>, then how would sumDigits(256, 16) -> 29<sub>10</sub>? Shouldn't it return 13<sub>10</sub>? --[[User:La Longue Carabine|La Longue Carabine]] 16:19, 23 July 2012 (UTC)
 
:::254 in base 16 has the digits with decimal values 15 and 14. Their sum when expressed in decimal notation is 29. In base 16, using hexadecimal digits, this sum might be represented as 1b = f + e. But we should get a different value for the sum of the digits of 256 -- in base 16, the digits have decimal values 1, 0 and 1, so their sum should be 1. That said, the base used to express the result need not have anything to do with the base used to perform the calculation. --[[User:Rdm|Rdm]] 16:54, 23 July 2012 (UTC)
6,951

edits