Skip to content

Commit

Permalink
add Sass function sqrt
Browse files Browse the repository at this point in the history
  • Loading branch information
kayo5994 committed Jan 2, 2019
1 parent b30c158 commit eb2a131
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions qmui/mixin/tool/_calculate.scss
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,20 @@
@return $result;
}

/// 获取数值的开平方值
///
/// @name sqrt
/// @param {Number} $number - 待开平方的数值
/// @example
/// sqrt(2) => 1.414214
@function sqrt($num) {
$temp:1;
@while abs($temp - $num / $temp) > 1e-6 {
$temp: ($temp + $num/$temp) / 2;
}
@return $temp;
}

/// 将数值格式化为指定小数位数的数字。
///
/// @name toFixed
Expand Down

0 comments on commit eb2a131

Please sign in to comment.