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?
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityThe 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}]
2^^1*^15, 2^^1*^14 ...
and convert it to hexadecimal.
$\endgroup$
Aug 21, 2016 at 11:46
*^
is not an operator that joins two expressions. It is part of the notation of numbers. This situation is completely equivalent to asking whyTable[1k3, {k, 1, 4}]
does not work for producing the four numbers{113,123,133,143}
. Use an explicit multiplier as inTable[num*base^k, {k, 0, 10}]
. $\endgroup$