Re: [Amforth] double-precision number to string conversion
Am Samstag, den 16.02.2019, 17:55 +0100 schrieb f.zelders--- via Amforth-devel: > Hello forth-professionals and fellow forth enthousiasts. > > I created a word that converts a positive double-precision number to > an 8 character string like this: > > : dpNumberToString ( d -- address count ) > <# # # # # # # # # #> ; > This works fine for positive numbers. > However I want to convert negative double-precision numbers too. Here's the code for d.r : d.r ( d n -- ) >r swap over dabs <# #s rot sign #> r> over - spaces type the essential part is that the "swap over dabs" creates a signed single cell number (value is not relevant) with the same sign as the double cell number and the double number is converted to a positive number (dabs). Inside the <# #> block, sign uses the signed number (again, numeric value irrelevant) to put the - (or nothing) in the picture numeric buffer (pic). Matthias ___ Amforth-devel mailing list for http://amforth.sf.net/ Amforth-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/amforth-devel
Re: [Amforth] double-precision number to string conversion
Hello Fred, f.zelders--- via Amforth-devel writes: > I created a word that converts a positive double-precision number to an 8 > character string like this: > > : dpNumberToString ( d -- address count ) > <# # # # # # # # # #> ; > This works fine for positive numbers. > However I want to convert negative double-precision numbers too. > > Any idea how I can make that work? Check out the definitions of "d." "d.r". common/words/d-dot.asm common/words/d-dot-r.asm At the end of these files there is equivalent forth code. Also be sure to check out Leo Brodie's "Starting Forth", chapter 7 on numbers: http://home.iae.nl/users/mhx/sf.html Cheers, Erich -- May the Forth be with you ... ___ Amforth-devel mailing list for http://amforth.sf.net/ Amforth-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/amforth-devel
[Amforth] double-precision number to string conversion
Hello forth-professionals and fellow forth enthousiasts. I created a word that converts a positive double-precision number to an 8 character string like this: : dpNumberToString ( d -- address count ) <# # # # # # # # # #> ; This works fine for positive numbers. However I want to convert negative double-precision numbers too. Any idea how I can make that work? Groeten uit Nederland! Fred ___ Amforth-devel mailing list for http://amforth.sf.net/ Amforth-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/amforth-devel