Re: SET DECIMALS Gotcha

Author: Laurie Alvey

Posted: 2017-07-31 at 06:19:17

This works:

x = 1.2345

SET DECIMALS TO 4

SET FIXED ON

? TRANSFORM(x, "999.9999")

Laurie

On 31 July 2017 at 11:34, Laurie Alvey <trukker41@gmail.com> wrote:

> SET DECIMALS TO n only works when SET FIXED is ON.

>

> Laurie

>

> On 30 July 2017 at 23:38, Gene Wirchenko <genew@telus.net> wrote:

>

>> Hello:

>>

>> I have just been bitten by SET DECIMALS. (Is there really any use

>> for this besides making programming just a bit more difficult?)

>>

>> I have a table with values to four decimal places. I use

>> <vfp>

>> transform(thevalue,"999999.9999")

>> </vfp>

>> to create the string representation. With SET DECIMALS set to its

>> default value, a value of 0.0123 is converted to " 0.0100" which loses

>> two digits of precision.

>>

>> I had this problem with another data item that had more than two

>> decimal places. I wrote a special function to handle it by setting SET

>> DECIMALS to the number of decimal places I needed, doing the transform(),

>> and setting SET DECIMALS back to the default.

>>

>> Why did I do that? Because the number of decimal places can vary

>> and I was generating a line of print in one line of code, BUT also, because

>> I really do not understand the point of SET DECIMALS.

>>

>> Could someone please clue me in?

>>

>> Sincerely,

>>

>> Gene Wirchenko

>>

>>

[excessive quoting removed by server]

_______________________________________________

Post Messages to: ProFox@leafe.com

Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox

OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech

Searchable Archive: http://leafe.com/archives/search/profox

This message: http://leafe.com/archives/byMID/profox/CAMvTR9fuNvuHmXGm9kyHEyj8ikkNArihqVVrJK_oG7rTFWq3Ow@mail.gmail.com

** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

©2017 Laurie Alvey