home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.forth      Forth programmers eat a lot of Bratwurst      117,927 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 117,179 of 117,927   
   dxf to Hans Bezemer   
   Re: "The Best Programming Language for t   
   09 Apr 25 20:35:41   
   
   From: dxforth@gmail.com   
      
   On 9/04/2025 6:42 pm, Hans Bezemer wrote:   
   > 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).   
      
   Also specify which of these should be displayed:   
      
   6 set-precision   
   0.000100000   
   0.0001       ( redundant trailing zeros removed)   
      
   For my money I'd have:   
      
   (F.) ( r n -- adr len )   
      
   From that an app or library can define F.R :   
      
   \ Print a string right-aligned in a field width characters   
   : S.R ( adr len width -- )  over - spaces type ;   
      
   : F.R ( r n width -- )  >r (f.) r> s.r ;   
      
   Or where the display mustn't exceed field-width ...   
      
   \ Per S.R but print asterisks if string exceeds width.  Assumes   
   \ adr len can be written to.   
   : ?S.R ( adr len width -- )   
     2dup > if  nip  2dup [char] * fill  dup  then  s.r ;   
      
   : ?F.R ( r n width -- )  >r (f.) r> ?s.r ;   
      
   --- SoupGate-DOS v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca