MathGroup Archive 1992

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

Search the Archive

converting from base to base...

  • To: mathgroup at yoda.physics.unc.edu
  • Subject: converting from base to base...
  • From: David Elbert <ELBERT at midd.bitnet>
  • Date: Thu, 26 Mar 1992 19:10 EST

Concerning "gaylord"'s problem of converting bases:

I think there is a misunderstanding of pg 357 of edition
2 of the big book.  The double carat (^^), is not a mathematical
function that can have its evaluation delayed, or accept a
variable for the value of "n" as in 2^^n.  This is purely an
input form device to allow you to enter a number from an
arbitrary base into Mma.  The number is immediately converted
to base 10.  The complement to this function is BaseForm[], which is
another purely formatting function that allows you to print out a number
in another base.  Try:

BaseForm[2^^101,3]

to see how they work.  It returns:

12
  3

which is a formatted way of writting 12 in base 3 (which is 101 in
base 2 or 5 in base 10).  If you then execute
%

you will see the result
5
Which demonstrates that the result of BaseForm is just a formatted
version of a number and so only applies to  one cell.  These just aren't
math functions.

It seems to me you may be able to use the age old method of
trickery/cleverness to avoid the problem.  Convert the numbers to base ten
by entering them with ^^ before you need to pass them around.  If you
really need have the conversion as a function..perhaps you have calculated
 a value in some other base and want to express it in base ten without
retyping it..I think you're sunk and will have to actually
write a little procedure to do base conversions.

Hope that helps the confusion even if it doesn't offer an answer.

-
David Elbert
Department of Geology
Middlebury College
Middlebury, VT 05753
Elbert at midd.bitnet






  • Prev by Date: Re: converting a number in base b to a number in base 10 using ^^ in Mathematica
  • Next by Date: MathLink Sample Program Problems
  • Previous by thread: Why won't MMA simplify parts of expressions?
  • Next by thread: MathLink Sample Program Problems