Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Xbase Fox > VFP 9: Making t...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 7 Topic 778 of 852
Post > Topic >>

VFP 9: Making transform() Drop Decimal 0's

by Gene Wirchenko <genew@[EMAIL PROTECTED] > Jun 8, 2007 at 12:17 PM

How do I print a number in simplest form?

     The numbers I have are specifed to two decimal places, but I do
not want trailing 0's or decimal point.  (I allow input of two decimal
places, but the precision does not need to be printed.)

     transform(5.30) gives "5.30", and I want "5.3".
     transform(5.00) gives "5.00", and I want "5".

     I also do not want any leading spaces.  I can ltrim() for that
though.

     I get a surprising result with overprecise constants:
          n=5.3000
          ? transform(n)     && outputs "5.3000"
          n=5.30
          ? transform(n)     && outputs "5.30"
          n=5.00
          ? transform(n)     && outputs "5"
I expected "5.00" from the last.

     What is the easiest way to deal with this?

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
     I have preferences.
     You have biases.
     He/She has prejudices.




 7 Posts in Topic:
VFP 9: Making transform() Drop Decimal 0's
Gene Wirchenko <genew@  2007-06-08 12:17:10 
Re: VFP 9: Making transform() Drop Decimal 0's
"Dan Freeman" &  2007-06-08 13:03:47 
Re: VFP 9: Making transform() Drop Decimal 0's
"Giancarlo Piccinato  2007-06-08 14:22:30 
Re: VFP 9: Making transform() Drop Decimal 0's
"Giancarlo Piccinato  2007-06-08 22:11:26 
Re: VFP 9: Making transform() Drop Decimal 0's
Gene Wirchenko <genew@  2007-06-09 22:46:46 
Re: VFP 9: Making transform() Drop Decimal 0's
tim_witort@[EMAIL PROTECT  2007-06-11 12:52:59 
Re: VFP 9: Making transform() Drop Decimal 0's
Gene Wirchenko <genew@  2007-06-09 22:41:40 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan13V112 Fri Jul 4 14:17:52 CDT 2008.