Jump to content

Binary digits: Difference between revisions

(→‎dt: add)
Line 2,077:
9000: 10001100101000
</pre>
 
=={{header|dt}}==
<syntaxhighlight lang="dt">[dup 1 gt? [dup 2 % swap 2 / loop] swap do?] \loop def
 
[\loop doin rev \to-string map "" join] \bin def
 
[0 1 2 5 50 9000] \bin map " " join pl</syntaxhighlight>
{{out}}
<pre>0 1 10 101 110010 10001100101000</pre>
 
=={{header|Dyalect}}==
 
A default <code>ToString</code> method of type <code>Integer</code> is overridenoverridden and returns a binary representation of a number:
 
<syntaxhighlight lang="dyalect">func Integer.ToString() {
Line 2,094 ⟶ 2,104:
print("5 == \(5), 50 = \(50), 1000 = \(9000)")</syntaxhighlight>
 
{{out}}
 
<pre>5 == 101, 50 = 110010, 1000 = 10001100101000</pre>
 
=={{header|EasyLang}}==
 
559

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.