Skip to content

Commit eb2a131

Browse files
committed
add Sass function sqrt
1 parent b30c158 commit eb2a131

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

qmui/mixin/tool/_calculate.scss

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,20 @@
121121
@return $result;
122122
}
123123

124+
/// 获取数值的开平方值
125+
///
126+
/// @name sqrt
127+
/// @param {Number} $number - 待开平方的数值
128+
/// @example
129+
/// sqrt(2) => 1.414214
130+
@function sqrt($num) {
131+
$temp:1;
132+
@while abs($temp - $num / $temp) > 1e-6 {
133+
$temp: ($temp + $num/$temp) / 2;
134+
}
135+
@return $temp;
136+
}
137+
124138
/// 将数值格式化为指定小数位数的数字。
125139
///
126140
/// @name toFixed

0 commit comments

Comments
 (0)