Binary digits: Difference between revisions

Content added Content deleted
(→‎min: update)
Line 3,589: Line 3,589:
io.write_string(int_to_base_string(N, 2), !IO),
io.write_string(int_to_base_string(N, 2), !IO),
io.nl(!IO).</syntaxhighlight>
io.nl(!IO).</syntaxhighlight>

=={{header|min}}==
=={{header|min}}==
{{works with|min|0.19.3}}
{{works with|min|0.37.0}}
<syntaxhighlight lang="min">(2 over over mod 'div dip) :divmod2
<syntaxhighlight lang="min">(
(dup 2 <) 'string
(dup odd? "1" "0" if swap 1 shr) 'prefix
linrec
) ^bin


(0 1 2 5 50 9000) 'bin map " " join puts!</syntaxhighlight>
(
:n () =list
(n 0 >) (n divmod2 list append #list @n) while
list reverse 'string map "" join
"^0+" "" replace ;remove leading zeroes
) :bin

(5 50 9000) (bin puts) foreach</syntaxhighlight>
{{out}}
{{out}}
<pre>0 1 10 101 110010 10001100101000</pre>
<pre>

101
110010
10001100101000
</pre>
=={{header|MiniScript}}==
=={{header|MiniScript}}==
=== Iterative ===
=== Iterative ===