# About a problem with FromDigits

I have tried FromDigits[{{1, 2, 3, 4},{2,3, 4, 1}, {3, 4, 1, 2}, {4, 1, 2, 3}}] and the result is as expected {1234,2341,3412,4123}. However for FromDigits[{{2,8},{8,2}}] the result is {28000000, 28}, and not the expected {28,82}. I wonder why this is the case?

• Perhaps you can gain some insight by studying the result of {#, # /. x -> 10} &@FromDigits[{{2, 8}, {8, 2}}, x]. Commented Jun 6, 2020 at 3:23
• Thanks for your suggestion. Let me see. Commented Jun 6, 2020 at 3:31

The documentation mentions (in a bullet point in "Details")

FromDigits[{list,n},b] takes n to be an exponent [...]

I think what's happening here is that it's taking {8,2} to be a list of exponents. Indeed, it turns out that FromDigits[{{2,8},{n,m}},b] gives

{b^(-2 + n) (8 + 2 b), b^(-2 + m) (8 + 2 b)}


which is somewhat surprising!

I guess if your list has more than two elements, it can't match the pattern {listofdigits, listofexponents} (e.g. {{__Integer},{__Integer}}), which is probably checked first. It's a bit frustrating that it's length-dependent like that, though; I guess it's safer to use something like FromDigits /@ listoflistsofdigits.

• Right, it's an edge case in the syntax specification, where on interpretation is used when another may have been expected. Commented Jun 6, 2020 at 20:10
• @thorimur: Thank you very much, your method works! Commented Jun 7, 2020 at 9:14