Liste des Groupes | Revenir à cl forth |
On 09-04-2025 04:21, dxf wrote:On 9/04/2025 1:15 am, dxf wrote:...>
It's not SET-PRECISION (presumably the implementer has made that sane)
but rather variability when values are sane e.g.
>>6 set-precision ok
1e-4 f. 0.000100000 ok
>
6 set-precision ok
1e-4 f. 0.0001 ok
While both of those are numerically correct, they're plainly different i.e.
11 characters vs. 6 characters. As an app writer I'd like some uniformity
here as I might want to output several columns of numbers on a screen. To
do that I need to know how wide to make those columns.
...
Iforth's F. was previously mentioned. In addition to treating PRECISION as
a decimal points specifier (ok it was their decision) F. includes mode
switching based on something called 'fieldwidth' for which I could find no
reference. Is mode switching good or bad? As always - it depends. I've
yet to see a bank statement with the balance displayed in scientific
notation. (But then I'm not Elon Musk so who knows.)
>
I mention this to demonstrate the variability that exists across forth -
presumably because Forth-94 chose not to think it through leaving folks
to their own devices. REPRESENT ? Well, I could rant about that too :)
I've never been an avid FP wordset user, so I must admit I've never delved so deep into it. But when I did (last night) I thought "Darn, he's right!"
1. I remember my spreadsheet having a way to set the number of decimals. So I looked there. It used F.R to use that result - and to my surprise (it seems .R little brother) AFAIK it's not part of the FP wordset;
2. So I looked in the standard (obvious when you're coming from F.R) and no - nothing special there: "Set the number of significant digits". Well that's helpful. But do you mean "significant digits" the way I mean "significant digits"? I don't think so.. The beauty of "most significant digits of the significand" didn't escape me, though. Merriam Webster, "significant": "of a noticeably or measurably large amount". Almost like "most", you mean. ;-)
3. If I can't find any help there, try elsewhere. Like C++. There "Precision" really means "Precision" - aka "the number of significant digits in the mantissa". Which in my book means 19 for a 64-bit mantissa and 9 for a 32-bit mantissa - if someone is unsure of what I mean. "fixed" however, is the keyword in C++ that switches this meaning to the number of decimals. If I understand you correctly, that's how iForth actually works.
I see two ways out of this:
a. Add F.R to the standard;
b. Add SET-DECIMALS or SET-FIXED to the standard.
And finally, add a section to the Annex to define and clarify the whole darn thing (because IMHO that is dearly missing).
Les messages affichés proviennent d'usenet.