gforth
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gforth] formatting numeric output


From: J. David Boyd
Subject: [gforth] formatting numeric output
Date: Wed, 07 Feb 2018 13:02:07 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (cygwin)

Is there an easier way to do this?

I want to format binary output, so I can see the hex-based groupings.

I mean, if I wanted to see hF00 as binary, or 3840d, it would come out as

0000 0000 0000 0000 0000 1111 0000 0000

so I can glance at it, and see that is equates to F 0 0.

The format function I came up with is

: b.s
  dup
  base @ >r binary
  0
  <<#
  # # # # bl hold
  # # # # bl hold
  # # # # bl hold
  # # # # bl hold
  # # # # bl hold
  # # # # bl hold
  # # # # bl hold
  # # # #
  #>
  TYPE SPACE
  #>>
  r> base ! ;

Is there any easier way than this that I am missing?

Thanks!




reply via email to

[Prev in Thread] Current Thread [Next in Thread]