注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号
x
LintCode上面的这道题, 虽然通过了,但对一些test case感到疑惑。虽然看起来简单,但也明白为什么会是Hard类型的。 如果 string="-3.5"或者negative decimal, AC的程序结果不正确。九章算法的程序也不对。
http://www.jiuzhang.com/solutions/binary-representation/
我的问题是这道题不需要考虑negative decimal吗?
Given a (decimal - e.g. 3.72) number that is passed in as a string, return the binary representation that is passed in as a string. If the fractional part of the number can not be represented accurately in binary with at most 32 characters, return ERROR.
Example
For n = "3.72", return "ERROR".
For n = "3.5", return "11.1". |