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



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.

.



Relevant Pages

  • Re: Interesting math
    ... precision when a number is zero. ... A C Float Number must have six or more significant digits ... and read about C Float Numbers and programming in C language. ...
    (alt.usage.english)
  • Re: Noise properties of a linear system if elements are deleted
    ... x contain useful information and which are expected to be zero. ... triangular form after first scaling any column of C to length one: ... Now using a unitary reflector U_1 we transform further ...
    (sci.math.num-analysis)
  • fpu code optimisation request
    ... Consider the following pseudo-code function: ... function myAND(float a, float b) ... Or, in "normal" language, zero stays zero, ...
    (comp.lang.asm.x86)
  • Re: is it safe to zero float array with memset?
    ... > No, but it's "safe enough". ... > that doesn't use all bits zero for float 0.0. ... If I were going to use memset() to zero an array of floats, ...
    (comp.lang.c)
  • Re: C2124 is most disrespectful of IEEE floating point arithmetic
    ... division of a non-zero by a zero to be a signed infinity, ... float inf; ... should result in a compile-time error, ... Am I being unreasonable in my expectations? ...
    (microsoft.public.vc.language)