Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #132062

Re: Display Engineering Notation with SI Prefix

Date 2024-08-29 20:02 +1000
Subject Re: Display Engineering Notation with SI Prefix
Newsgroups comp.lang.forth
References <66cf431d$1@news.ausics.net>
From dxf <dxforth@gmail.com>
Message-ID <66d04731$1@news.ausics.net> (permalink)
Organization Ausics - https://newsgroups.ausics.net

Show all headers | View raw


On 29/08/2024 1:32 am, dxf wrote:
> \ Display Engineering Notation with SI Prefix
> \
> \ Note: If DX-Forth, VFX Forth or Win32Forth with
> \ replacement f/p package is available then the code
> \ block defining (FE.) may be disabled.
> \
> \ Inspired by iForth's (F.N) functions
> \
> \ This code is Public Domain
> 
> https://pastebin.com/jd676RC7

The (FE.) simulation didn't work for PREC < 3 .  Here's a fix:

: (FE.) ( r n -- adr len )  \ *** only handles n = -1 ***
  drop  fb 3 [char] 0 fill  fb precision represent  <#  if
    >r  1- s>d 3 fm/mod 3 *  dup  abs 0 #s  rot sign
    [char] E hold  rot  fb precision  3 max  rot 1+ /str
    [char] 0 trim  tuck  holds  if  [char] . hold  then
    holds  r> sign
  else  fb precision -trailing  holds  then  #> ;

The following now works ...

1.234e 1e2 f* 2 1 (eng.) type 120  ok

The real (FE.) has no such issues and works as expected ...

VFX Forth 64 for Windows x64
  © MicroProcessor Engineering Ltd, 1998-2023 

 Version: 5.43 [build 4241]
 Build date: 22 December 2023

2 set-precision  ok
1.234e 1e2 f* -1 (fe.) type 120.E0 ok

Back to comp.lang.forth | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Display Engineering Notation with SI Prefix dxf <dxforth@gmail.com> - 2024-08-29 01:32 +1000
  Re: Display Engineering Notation with SI Prefix dxf <dxforth@gmail.com> - 2024-08-29 20:02 +1000
    Re: Display Engineering Notation with SI Prefix mhx@iae.nl (mhx) - 2024-08-29 10:39 +0000
      Re: Display Engineering Notation with SI Prefix dxf <dxforth@gmail.com> - 2024-08-29 22:39 +1000
        Re: Display Engineering Notation with SI Prefix mhx@iae.nl (mhx) - 2024-08-29 14:23 +0000
          Re: Display Engineering Notation with SI Prefix dxf <dxforth@gmail.com> - 2024-08-30 12:13 +1000
            Re: Display Engineering Notation with SI Prefix mhx@iae.nl (mhx) - 2024-08-30 06:30 +0000
              Re: Display Engineering Notation with SI Prefix dxf <dxforth@gmail.com> - 2024-08-30 18:03 +1000
                Re: Display Engineering Notation with SI Prefix mhx@iae.nl (mhx) - 2024-08-30 08:26 +0000
                Re: Display Engineering Notation with SI Prefix dxf <dxforth@gmail.com> - 2024-08-30 19:24 +1000
                Re: Display Engineering Notation with SI Prefix dxf <dxforth@gmail.com> - 2024-08-31 11:11 +1000

csiph-web