营养数据计算优化;人脸增加数据处理;其它优化;
This commit is contained in:
@@ -20,6 +20,8 @@ import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.math.BigDecimal
|
||||
import java.math.RoundingMode
|
||||
|
||||
/**
|
||||
* 将 Int 值转换为 dp 值
|
||||
@@ -65,6 +67,10 @@ val Float.sp: Float
|
||||
Resources.getSystem().displayMetrics
|
||||
)
|
||||
|
||||
fun Double.roundedDecimalPlace(num: Int = 2): Double {
|
||||
return BigDecimal(this).setScale(num, RoundingMode.HALF_UP).toDouble()
|
||||
}
|
||||
|
||||
fun Double?.format2String(): String = this.format2String(1)
|
||||
fun Double?.format2String(num:Int): String = "%.${num}f".format(this?:0.0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user