add #DFP for Decimal Fixed Precision numeric output

This commit is contained in:
Jesse D. McDonald 2020-10-27 01:56:26 -05:00
parent 67bb06dd8f
commit 687012b7df
1 changed files with 4 additions and 0 deletions

View File

@ -740,6 +740,10 @@ CREATE PNO-POINTER PNO-BUFFER-END ,
: #S ( ud -- ) 10 #SB ;
\ Decimal Fixed Precision with u digits after the decimal point
\ Example: 12345 0 <# 3 #DFP #> ≡ "12.345"
: #DFP ( ud1 u -- ud2 ) BEGIN ?DUP WHILE 1- >R # R> REPEAT [CHAR] . HOLD #S ;
\ Display the unsigned number at the top of the stack
: DU. ( ud -- "<digits>" ) <# #S #> TYPE ;
: U. ( u -- "<digits>" ) 0 DU. ;