I notice that there is a syntax to enter a numeric literal in a different base, for example:

In[8]:= 5^^1000000000000101
Out[8]= 30517578151

However, there does not seem to be any function to enter a number in a different base. Since, it seems practically every operation in Mathematical has a corresponding function, this seems strange. Also, the documentation for ^^ is hidden in the BaseForm function's documentation, and is just barely mentioned. It is not listed as an operator at all.

This weird syntax is a problem for me. For example, I tried to display a number in different bases like this:

Map[(#^^1000000000000101) &, Range[2, 10]]

and it gives an error.


FromDigits can do the job:

FromDigits["1000000000000101", Range[2, 10]]

(* {32773, 14348917, 1073741841, 30517578151, 470184984613,
    4747561509993, 35184372088897, 205891132094731, 1000000000000101} *)
  • $\begingroup$ Yes, I knew about this command but it seemed like "cheating" because you are actually treating the number as a string. It does not actually handle the value numerically the way ^^ does. $\endgroup$ – Tyler Durden Apr 9 '16 at 19:17
  • $\begingroup$ ^^ also treats the digits as a string even though syntactically it allows us to omit the quotes. Consider: 16^^face == FromDigits["face", 16]. $\endgroup$ – WReach Apr 9 '16 at 19:23
  • $\begingroup$ Or, with a number use FromDigits[IntegerDigits[1000000000000101], Range[2, 10]] $\endgroup$ – Bob Hanlon Apr 9 '16 at 20:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.