1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (English)/二进制数转字符串(English) [binary-number-to-string-lcci].html
2023-05-15 17:43:00 +08:00

24 lines
800 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 &quot;ERROR&quot;.</p>
<p><strong>Example1:</strong></p>
<pre>
<strong> Input</strong>: 0.625
<strong> Output</strong>: &quot;0.101&quot;
</pre>
<p><strong>Example2:</strong></p>
<pre>
<strong> Input</strong>: 0.1
<strong> Output</strong>: &quot;ERROR&quot;
<strong> Note</strong>: 0.1 cannot be represented accurately in binary.
</pre>
<p><strong>Note: </strong></p>
<ul>
<li>This two charaters &quot;0.&quot; should be counted into 32 characters.</li>
<li>The number of decimal places for <code>num</code> is at most 6 digits</li>
</ul>