Re: question on changing 'type' of numbers

• To: mathgroup at smc.vnet.net
• Subject: [mg69486] Re: [mg69473] question on changing 'type' of numbers
• From: Bob Hanlon <hanlonr at cox.net>
• Date: Thu, 14 Sep 2006 06:55:02 -0400 (EDT)

```Applying Integer (or Real) to a value just returns the value. The argument of Head is "evaluated" and are asking for the Head of the value.

Clear[x];

Apply[Integer,x]

x

Symbol

x=0.1;

Apply[Integer,x]

0.1

Real

You can assign a Head to a symbol

Clear[x];

Real

Integer

x=0.1

0.1

??x

Global`x

x = 0.1

Real

Again you get the Head of the value not the Head assigned to the symbol

Bob Hanlon

---- Nasser Abbasi <nma at 12000.org> wrote:
> I think of a the Head of expression as its 'type'.
>
> One is supposed to be able to use Apply[f,expr] to change head of expression
> to f.
>
> But Why can't I use this to change the head of a Real number to Integer?
>
> In[122]:=
> Remove["Global`*"]
> x = 0.1
>            -------------->Real
> Apply[Integer,x]
>         ------------------->Real. I was expecting Intger
> x = Integer[x]
>       ----------------> Now it says Integer
>
> any idea?
>
> ofcourse the question as to what should happen to the value of the variable
> if for example I change the head of 0.5 from Real to Integer is another
> matter. It seems in this case x remained 0.1 but only the head said Integer
>
> x
> ----->Integer[0.1]
>
> Now sure what the above really means :)
>
> Nasser
>

```

• Prev by Date: Re: Re: init.m of FrontEnd in M5.2
• Next by Date: common problem with FindMinimum and NIntegrate
• Previous by thread: Re: RE: question on changing 'type' of numbers
• Next by thread: Re: question on changing 'type' of numbers