Re: question on changing 'type' of numbers
- To: mathgroup at smc.vnet.net
- Subject: [mg69484] Re: question on changing 'type' of numbers
- From: dh <dh at metrohm.ch>
- Date: Thu, 14 Sep 2006 06:54:54 -0400 (EDT)
- References: <ee8h72$j38$1@smc.vnet.net>
Hi Nasser , I believe the answer is that 0.1 is an atom not an expression. The Help says:"Head[expr] gives the head of expr" Head[atom] seems to give the type of the atom. Integer[0.1] is an expression, namely the function Integer with the argument 0.1. As there is no such function defined, the expression is not further evaluated. Daniel Nasser Abbasi 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 > Head[x] > -------------->Real > Apply[Integer,x] > Head[x] > ------------------->Real. I was expecting Intger > x = Integer[x] > Head[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 >