converting a number in base b to a number in base 10 using ^^ in Mathematica

• To: mathgroup at yoda.physics.unc.edu
• Subject: converting a number in base b to a number in base 10 using ^^ in Mathematica
• From: gaylord at ux1.cso.uiuc.edu
• Date: Thu, 26 Mar 1992 04:44:33 -0600

```on p. 537 of the second edition of the bible it says that

to go from a number 'mmm' in base b to a number in base 10 use

b^^mmm

eg.,

2^^101
5

writing a program to do this,

base2tobase10conversion[n_Integer] := 2^^n

however, when this is entered into the global rule base, i got

base2tobase10conversion[n_Integer] := 2^^n
General::digit:
Digit at position 1 in n
is too large to be used in
base 2.

hoping it was one of those messages that don't mean much, i tried to run
the program

base2tobase10conversion[101]
\$Failed

what's going on apparently is that M wants the quantity to the right of ^^
to be an integer. i tried to use Hold to avoid the problem but it doesn't
help.

i then tried :

101
101

2^^%
Syntax::sntxf:
"2^" cannot be followed by "^%"

it seems that the ^^ operator absolutely insists on being immediately
followed by an integer.

can someone suggest another way (there must be; there's always another way
to do almost everything in M) to convert a number in base b to base 10
other than using ^^.

i find it hard to believe that M does not have a built-in function for
doing this but i can't find it in the book.

```

• Prev by Date: Re: Ceiling & Floor
• Next by Date: Re: converting a number in base b to a number in base 10 using ^^ in Mathematica
• Previous by thread: Re: Nodal
• Next by thread: Re: converting a number in base b to a number in base 10 using ^^ in Mathematica