# Why 2^^1*^k does not work?

Table[2^^1*^k,{k,0,10}]


This gives an error, why is that?

Also this BaseForm[2 ** 1*^ #, 16] & /@ Range[10]

What is wrong here?

• If you explain the output you expect, someone may be able to help you. – mikado Aug 20 '16 at 8:03
• I didn’t think that the output where important, but i try to explain it in the comment to the answer of Mr.Wizard. – kafkarudo Aug 21 '16 at 11:50
• It doesn't work because *^ is not an operator that joins two expressions. It is part of the notation of numbers. This situation is completely equivalent to asking why Table[1k3, {k, 1, 4}] does not work for producing the four numbers {113,123,133,143}. Use an explicit multiplier as in Table[num*base^k, {k, 0, 10}]. – Szabolcs Aug 22 '16 at 9:26

The number entry form base^^digits is only valid for explicit [0-9] digits in the place of both base and digits. You cannot write literal b^^1001 and then attempt to replace b as b^^1001 does not parse to this input form.

Likewise the number entry form m*^exp is only valid for explicit [0-9] digits in the place of both m and exp.

The combination of these entry forms does work, but possibly not in the manner you intend. (One must guess your intent.) For example 2^^1001*^12 inputs 36864, because 1001*^12 is first converted to 1001000000000000 and then 2^^1001000000000000 becomes 36864.

Responding to the comment below, if the combined behavior is what you want you could "force" this evaluation by assembling a String and then converting it to an Expression using ToExpression:

Table[ToExpression[ "2^^1*^" <> ToString[k] ], {k, 0, 10}]

{1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024}


This however makes one wonder why you would not simply write:

2^Range[0, 10]

{1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024}


Or more generally:

Table[2^^1001 * 2^k, {k, 0, 10}]

{9, 18, 36, 72, 144, 288, 576, 1152, 2304, 4608, 9216}


Equivalent to:

 Table[ToExpression["2^^1001*^" <> ToString[k]], {k, 0, 10}]

• Sorry if wasn’t clear with my problem. Yes that was exactly the behaviour that i was expecting. I’m working with a digital bus that takes 16bits in binary and only 1 bit at the time is on ( 1 ). So I want a list of 15 numbers 2^^1*^15, 2^^1*^14 ... and convert it to hexadecimal. – kafkarudo Aug 21 '16 at 11:46
• @kafkarudo please see my updated answer. – Mr.Wizard Aug 21 '16 at 20:17
• Thanks Mr.Wizard, “It’s not the destination, but the journey, that matters” – kafkarudo Aug 25 '16 at 9:34
• @kafkarudo You're welcome. :-) – Mr.Wizard Aug 25 '16 at 11:39