Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content
🚀 Try FlipJump in your browser: fj.tomhe.app
FlipJump Docs
FlipJump Docs
  • Getting Started
    • Installation
    • Hello, World!
    • Anatomy of a FlipJump program
  • Cookbook
    • Hello, World!
    • Echo a byte
    • Print a number in decimal
    • Conditional branches
    • Loop N times
    • Read, transform, print
    • Swap two variables
    • Add two numbers
    • Call a function
    • Define and print a string variable
  • Language Reference
    • The FlipJump Instruction
    • Lexical Structure
    • Expressions
    • Macros
    • Namespaces
    • Directives
    • Types and built-in names
    • Input / Output
    • Complexity notation
  • Standard Library
    • runlib.fj
    • casting.fj
    • ptrlib.fj
    • bit — namespace overview
      • bit/memory.fj
      • bit/logics.fj
      • bit/cond_jumps.fj
      • bit/shifts.fj
      • bit/math.fj
      • bit/input.fj
      • bit/output.fj
      • bit/casting.fj
      • bit/pointers.fj
      • bit/mul.fj
      • bit/div.fj
    • hex — namespace overview
      • hex/memory.fj
      • hex/logics.fj
      • hex/math.fj
      • hex/math_basic.fj
      • hex/shifts.fj
      • hex/cond_jumps.fj
      • hex/tables_init.fj
      • hex/input.fj
      • hex/output.fj
      • hex/mul.fj
      • hex/div.fj
      • hex.pointers — namespace overview
        • hex/pointers/basic_pointers.fj
        • hex/pointers/xor_to_pointer.fj
        • hex/pointers/xor_from_pointer.fj
        • hex/pointers/read_pointers.fj
        • hex/pointers/write_pointers.fj
        • hex/pointers/stack.fj
        • hex/pointers/pointer_arithmetics.fj
    • All macros — alphabetical index
  • Reference
    • FlipJump in 5 minutes
    • Glossary
    • How the STL works
  • Examples
    • Hello World
    • Prime Sieve
    • Calculator
    • Quine
  • Companion tools and resources
    • FlipJump IDE — fj.tomhe.app
    • c2fj — C to FlipJump
    • bf2fj — Brainfuck to FlipJump
    • flip-jump — the upstream language repo
    • esolangs.org — the canonical external reference
Back to top
View this page
Edit this page

Print a number in decimal¶

Problem¶

Convert a binary value to its decimal ASCII representation and print it.

Code¶

stl.startup
bit.print_dec_uint 32, n
stl.output '\n'
stl.loop

n: bit.vec 32, 12345

Walkthrough¶

  • n: bit.vec 32, 12345 — allocate a 32-bit variable initialised to 12345. The initial value is encoded at assembly time as bit-flips into the variable’s region.

  • bit.print_dec_uint 32, n — divides n by 10 repeatedly, printing each remainder as the corresponding '0'–'9' ASCII byte. The macro runs in n²·(2@+4) time; the comment in the source notes the 28/93 ratio used to size the print buffer.

Variations¶

Signed integers (handles negative numbers + leading -):

stl.startup
bit.print_dec_int 32, signed_val
stl.output '\n'
stl.loop

signed_val: bit.vec 32, 0 - 12345     // -12345

Hex instead of decimal — much cheaper, no division loop:

stl.startup
bit.print_hex_int 32, n, 1   // last arg = "uppercase digits"
stl.output '\n'
stl.loop

n: bit.vec 32, 0xCAFE

See also¶

  • bit.print_dec_uint

  • bit.print_dec_int

  • bit.print_hex_int

  • The Complexity glossary — to understand n²·(2@+4).

Next
Conditional branches
Previous
Echo a byte
Copyright © 2026, Tom Herman
Made with Sphinx and @pradyunsg's Furo
On this page
  • Print a number in decimal
    • Problem
    • Code
    • Walkthrough
    • Variations
    • See also