mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 19:18:14 +08:00
23 lines
696 B
HTML
23 lines
696 B
HTML
|
<p>Given a real number between 0 and 1 (e.g., 0.72) that is passed in as a double, print the binary representation. If the number cannot be represented accurately in binary with at most 32 characters, print "ERROR".</p>
|
||
|
|
||
|
<p><strong>Example1:</strong></p>
|
||
|
|
||
|
<pre>
|
||
|
<strong> Input</strong>: 0.625
|
||
|
<strong> Output</strong>: "0.101"
|
||
|
</pre>
|
||
|
|
||
|
<p><strong>Example2:</strong></p>
|
||
|
|
||
|
<pre>
|
||
|
<strong> Input</strong>: 0.1
|
||
|
<strong> Output</strong>: "ERROR"
|
||
|
<strong> Note</strong>: 0.1 cannot be represented accurately in binary.
|
||
|
</pre>
|
||
|
|
||
|
<p><strong>Note: </strong></p>
|
||
|
|
||
|
<ol>
|
||
|
<li>This two charaters "0." should be counted into 32 characters.</li>
|
||
|
</ol>
|