Mathematica 9 is now available
Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: Simple Problem ??

  • To: mathgroup at
  • Subject: [mg39261] RE: [mg39226] Simple Problem ??
  • From: "Wolf, Hartmut" <Hartmut.Wolf at>
  • Date: Thu, 6 Feb 2003 03:08:17 -0500 (EST)
  • Sender: owner-wri-mathgroup at


you've got replies that do what you want. The problem however is not to mix
up numbers with strings (denoting numbers). Let me introduce what, I think,
are Mathematica's notions:

A number is a number, i.e. a mathematical object, it has no base, and such
cannot be converted to a different base. 


In[46]:= Nest[Prime, 1, 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1] a denotation of a number not involving any base. The answer of
Mathematica is

Out[46]= 648391

In decimal form, just to our educated eyes, perhaps not quite so for the
Babylonians. To enjoy Leibniz, we might just do

In[47]:= BaseForm[%, 2]

Clearly this is a string (as was the printed form of Out[46]). 

To enter a number we have to do quite the converse; again decimals are in
favour and we don't normally recognize what we are doing. In Mathematica we
have got a choice yet:

In[39]:= n = 2^^1000111
Out[39]= 71

In[40]:= BaseForm[n, 2]

In[41]:= % + 1
Out[41]= 72

The part "^^" of the input string "2^^1000111" is not a Mathematica Operator
but a terminal of input syntax. It is parsed on reading input to encode the
denoted number correctly.

The input syntax "^^" (number base)and the printing form BaseForm have their
limitations though (see also The Book §3.1.3, A.2.5). Perhaps you liked to
check out

In[81]:= IntegerDigits[n, 2]
Out[81]= {1, 0, 0, 0, 1, 1, 1}

In[82]:= FromDigits[Rest[%], 2]
Out[82]= 7

In[84]:= IntegerDigits[n, 50, 3]
Out[84]= {0, 1, 21}

where we're back at mathematics.

Hartmut Wolf

>-----Original Message-----
>From: AON NEWS [mailto:frodo.biggins at]
To: mathgroup at
>Sent: Tuesday, February 04, 2003 8:23 AM
>To: mathgroup at
>Subject: [mg39261] [mg39226] Simple Problem ??
>it seems I have a simple problem, but I cannot find a (simple)solution:
>if I type 2^^1000111 mathematica calculates the correct dec. number
>but if I type: base=2; number=1000111; base^^number  all I get 
>is a error
>message ???
>So a function Convert[number_,base_] for base convertions 
>cannot work ...
>Any ideas
>Prof. Mag. Werner CYRMON
>HTBLuVA Wr. Neustadt Abt. EDVO
>If you can imagine it, you can do it! Walt Disney
>Want to learn math with fun or calculating some stuff online:
>Look at

  • Prev by Date: Re: Interpolation over an irregular surface
  • Next by Date: Re: Complex root finding
  • Previous by thread: Re: Simple Problem ??
  • Next by thread: Re: RealOnly (Correction)