Decimal floating point number to binary: Difference between revisions

Rename Perl 6 -> Raku, alphabetize, minor clean-up
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 20:
 
</lang>
 
=={{header|dc}}==
{{works with|dc|1.3.95 (GNU bc 1.06.95)}}
Interactively:
<lang bash>$ dc
2o
23.34375 p
10111.01011000000000000
$ dc
2i
1011.11101
11.90625
$</lang>
 
Directly on the command line:
<lang bash>$ dc -e '2o 23.34375 p'
10111.01011000000000000
$ dc -e '2i 1011.11101 p'
11.90625
$ echo '2o 23.34375 p' | dc
10111.01011000000000000
$ echo '2i 1011.11101 p' | dc
11.90625
$</lang>
 
From the manpage: "To enter a negative number, begin the number with '_'. '-' cannot be used for this, as it is a binary operator for subtraction instead."
<lang bash>$ dc -e '2o _23.34375 p'
-10111.01011000000000000
$ dc -e '2i _1011.11101 p'
-11.90625
$</lang>
 
=={{header|D}}==
Line 124 ⟶ 90:
-23.3438
11.906250</pre>
 
=={{header|dc}}==
{{works with|dc|1.3.95 (GNU bc 1.06.95)}}
Interactively:
<lang bash>$ dc
2o
23.34375 p
10111.01011000000000000
$ dc
2i
1011.11101
11.90625
$</lang>
 
Directly on the command line:
<lang bash>$ dc -e '2o 23.34375 p'
10111.01011000000000000
$ dc -e '2i 1011.11101 p'
11.90625
$ echo '2o 23.34375 p' | dc
10111.01011000000000000
$ echo '2i 1011.11101 p' | dc
11.90625
$</lang>
 
From the manpage: "To enter a negative number, begin the number with '_'. '-' cannot be used for this, as it is a binary operator for subtraction instead."
<lang bash>$ dc -e '2o _23.34375 p'
-10111.01011000000000000
$ dc -e '2i _1011.11101 p'
-11.90625
$</lang>
 
=={{header|Elixir}}==
Line 885:
23.34375 => 10111.01011
1011.11101 => 11.90625</pre>
 
 
=={{header|OCaml}}==
Line 1,189 ⟶ 1,188:
11.90625</pre>
 
=={{header|Perl 6}}==
<lang perl6>given "23.34375" { say "$_ => ", :10($_).base(2) }
given "1011.11101" { say "$_ => ", :2($_).base(10) }</lang>
{{out}}
<pre>23.34375 => 10111.01011
1011.11101 => 11.90625</pre>
=={{header|Phix}}==
Handles bases 2..36. Does not handle any form of scientific notation.
Line 1,401 ⟶ 1,394:
"1.000000000"
0.99951171875</pre>
 
=={{header|Perl 6Raku}}==
(formerly Perl 6)
<lang perl6>given "23.34375" { say "$_ => ", :10($_).base(2) }
given "1011.11101" { say "$_ => ", :2($_).base(10) }</lang>
{{out}}
<pre>23.34375 => 10111.01011
1011.11101 => 11.90625</pre>
 
=={{header|REXX}}==
Line 1,687 ⟶ 1,688:
}</lang>
{{Out}}Experience running it in your browser by [https://scastie.scala-lang.org/auzWgFqCRBaYoOaJV92tgw Scastie (remote JVM)].
 
=={{header|Sidef}}==
<lang ruby>func dec2bin(String n) {
10,333

edits