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