RE: VFP 9: Making transform() Drop Decimal 0's
- From: Mark <Mark@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 12 Jun 2007 13:45:00 -0700
Hi Gene, hi Roger
from the VFP6 Helpfile:
Numeric (includes Double, Float, or Integer data types):
Trailing zeros are removed from the decimal portion of a numeric value.If the numeric value is a whole number, a decimal point is not included in
the
transformed value (for example, 4.0 is transformed to 4). If the numeric
value is less than one but greater than negative one, zero is included before
the decimal point (for example, .4 is transformed to 0.4).
As I'm still working with VFP 6, this explains my results.
Your quotes:
Removes trailing zeros from the decimal portion of a numeric value
when all the numbers following the decimal point are zeros.
If the numeric value is a whole number, a decimal point is not
included in the transformed value, for example,
4.0 is transformed to 4.
If the numeric value is less than one but greater than negative one,
zero is included before the decimal point, for example,
.4 is transformed to 0.4.
This would explain your results. Hence "they" changed the behaviour of
Transform() to the worse!
Mark
"Mark" wrote:
Hi Gene,.
from the VFP6 Helpfile:
Numeric (includes Double, Float, or Integer data types):
Trailing zeros are removed from the decimal portion of a numeric value. If
the numeric value is a whole number, a decimal point is not included in the
transformed value (for example, 4.0 is transformed to 4). If the numeric
value is less than one but greater than negative one, zero is included before
the decimal point (for example, .4 is transformed to 0.4).
hth
Mark
"Gene Wirchenko" wrote:
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.
- Follow-Ups:
- Re: VFP 9: Making transform() Drop Decimal 0's
- From: Roger Ansell
- Re: VFP 9: Making transform() Drop Decimal 0's
- From: Gene Wirchenko
- Re: VFP 9: Making transform() Drop Decimal 0's
- Prev by Date: Re: LZO in FoxPro
- Next by Date: Re: Attemping to convert a FPW26 prog to VFP9
- Previous by thread: Re: VFP 9: Making transform() Drop Decimal 0's
- Next by thread: Re: VFP 9: Making transform() Drop Decimal 0's
- Index(es):
Relevant Pages
|