Group Abstract Group Abstract

Message Boards Message Boards

0
|
8.2K Views
|
6 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Why doesn't this work in Mathematica, cu[x_] := BaseForm[2^^x, 16] ?

Posted 11 years ago

Why doesn't this work in Mathematica,

cu[x_] := BaseForm[2^^x, 16] ?
POSTED BY: Roger Backhus
6 Replies
POSTED BY: Isaac Abraham

The 2^^1010 immediately evaluates to 10, as seen from,

BaseForm[2^^1010,16]//FullForm (*Out[]:= BaseForm[10,16]*)

When we replace the 1010 with a symbol x, The outer wrapper BaseForm cannot immediately evaluate its argument in x, resulting in the expressions about incomplete expression. I see it similar to how we can't add the following although the lists themselves will sum.

 MatrixForm[{{3,2},{3,4}}]+MatrixForm[{{1,2},{3,4}}] (*Out[]:= Two matrices in textbook notation. *)

whereas,

{{3,2},{3,4}}+{{1,2},{3,4}}; (*Out[]:= {{4,4},{6,8}} *)
POSTED BY: Isaac Abraham
Posted 11 years ago

Well, ok but I can enter, BaseForm[2^^1010,16] and get the correct answer.

Thanks.

POSTED BY: Roger Backhus
POSTED BY: Isaac Abraham
Posted 11 years ago

If I have the binary number, say, 1010, and type 2^^1010, then Mathematica will give me the value of the number in base 10. So, 2^^1010 will result in 10. Also, if I have 0xA and I type 16^^A then I will also get 10.

POSTED BY: Roger Backhus

what's 2^^x ?

POSTED BY: Kay Herbert
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard