Skip to content

Commit

Permalink
修复小数位不存在报错的情况
Browse files Browse the repository at this point in the history
  • Loading branch information
qqlcbb committed Mar 7, 2019
1 parent 2c6b918 commit 27356d1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion php/15_binary/binary.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ function squareRoot($number)
function getDecimalPlaces($number)
{
$temp = explode('.', $number);
return strlen($temp[1]);
if (isset($temp[1])) {
return strlen($temp[1]);
}

return 0;
}

// 测试二分查找给定值
Expand Down

0 comments on commit 27356d1

Please sign in to comment.