MathGroup Archive 2007

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

Search the Archive

Re: From PaddedForm to numbers?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg80499] Re: From PaddedForm to numbers?
  • From: David Bailey <dave at Remove_Thisdbailey.co.uk>
  • Date: Thu, 23 Aug 2007 06:23:05 -0400 (EDT)
  • References: <faj6fp$9gt$1@smc.vnet.net>

Curtis Osterhoudt wrote:
> Hi, all, 
> 
>    Given a number in PaddedForm, how can I easily convert it to a number which 
> can be worked with? This would be the analogue of ToExpression[ 
> some_string_representing_a_number ]. 
> 
>         Thanks!
> 
> 
PaddedForm is a wrapper - like MatrixForm, and many others. WRI have a 
standard comment in relation to these - "PaddedForm acts as a ?wrapper?, 
which affects printing, but not evaluation."

The wording of this has always seemed to me unfortunate, because if you 
leave wrapper round an object it looks OK, but can't be incorporated in 
  a further calculation - in other words a wrapper certainly does affect 
evaluation!

The ideal solution to your problem is to use PaddedForm inside a Print 
statement so that it does not remain part of a stored expression. I 
assume you have an expression such as:

xx=PaddedForm[22,4];

This sets xx to a PaddedForm structure - as can be observed by looking 
at xx in FullForm:

FullForm[xx]

If you really need to re-activate PaddedForm structures - rather than 
just avoid them, you could use:

yy /. PaddedForm[x_,_]->x

where yy can be any expression involving zero or more PaddedForm constructs.

David Bailey
http://www.dbaileyconsultancy.co.uk



  • Prev by Date: Contour plot legend
  • Next by Date: Re: On partitioning lists by intervals
  • Previous by thread: Re: From PaddedForm to numbers?
  • Next by thread: Re: Re: From PaddedForm to numbers?