problem changing ibase



2012/11/22 Antonio Lapira <antoniolapira at yahoo.it>

> ok
>
> and what about if I want to sum numbers in different bases?
> for example 10101010 (in binary) + 150 (in decimal) + ff (in hex)?
> Is it possibile or  I need to convert them before adding?
>

The parser needs to know the changed ibase before parsing. The following is
a possible solution.

(%i1) in_base(base, num_as_string) :=
block([ibase : base], parse_string(num_as_string))$

(%i2) in_base(2, "10101010") + 150 + in_base(16, "0ff");
(%o2)                                 575

HTH
Volker van Nek



>
>
> --- *Gio 22/11/12, Stavros Macrakis <macrakis at alum.mit.edu>* ha scritto:
>
>
> Da: Stavros Macrakis <macrakis at alum.mit.edu>
> Oggetto: Re: [Maxima] problem changing ibase
> A: "Antonio Lapira" <antoniolapira at yahoo.it>
> Cc: maxima at math.utexas.edu
> Data: Gioved? 22 novembre 2012, 17:34
>
>
> As Bill Wood says, in %i3, "10" means 2.  For %i4, try ibase:1+1$
>
> On Thu, Nov 22, 2012 at 12:01 PM, Antonio Lapira <antoniolapira at yahoo.it<http://mc/compose?to=antoniolapira at yahoo.it>
> > wrote:
>
> I have problems swithing among bases
>
> for example:
> (%i1) ibase:16$
> (%i2) ibase:2$
> (%i3) ibase:10$
> (%i4) ibase:2$
>
> assignment: cannot assign 2 to ibase
>  -- an error. To debug this try: debugmode(true);
>
> why?
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu <http://mc/compose?to=Maxima at math.utexas.edu>
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
>
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
>