diff --git a/general/inc/utils.h b/general/inc/utils.h index 340b4c4..58e2ba8 100644 --- a/general/inc/utils.h +++ b/general/inc/utils.h @@ -35,5 +35,8 @@ inline ENV_COMPILER CurrentEnvCompiler(); string itos(int x); +// 限制float精确度 +float LimitFloat(float in,int size); + #endif //CUTILS_UTILS_H diff --git a/general/src/encrypt/aes.cpp b/general/src/encrypt/aes.cpp index 153da32..e643343 100644 --- a/general/src/encrypt/aes.cpp +++ b/general/src/encrypt/aes.cpp @@ -1,6 +1,3 @@ -// -// Created by 29019 on 2020/1/4. -// #include "aes.h" #include diff --git a/general/src/loger.cpp b/general/src/loger.cpp index 4565893..f8b56e1 100644 --- a/general/src/loger.cpp +++ b/general/src/loger.cpp @@ -116,6 +116,7 @@ int Loger::Error(string dat,string function,int line) { return 0; } + int Loger::Warning(string dat,string function,int line) { if(mLevel > LEVEL_WARNING) { return 0; @@ -343,7 +344,7 @@ Loger::Loger(string path,string prefix,bool old) { }else{ this->mFile = fopen(this->mCurrentPath.c_str(),"a+"); } - if(! this->mFile){ + if(!this->mFile){ fprintf(stderr,"error open log files %s code %d,please check file path",this->mCurrentPath.c_str(),errno); exit(0); }else{ diff --git a/general/src/utils.cpp b/general/src/utils.cpp index a516e61..f2a2d93 100644 --- a/general/src/utils.cpp +++ b/general/src/utils.cpp @@ -62,3 +62,17 @@ inline ENV_COMPILER CurrentEnvCompiler() } + +// 限制float有效位 +float LimitFloat(float in,int size){ + uint64_t tmp = 1; + for(int i = 0;i < size;i++){ + tmp = tmp*10; + } + uint64_t integer = uint64_t(in * tmp); // 提取整数部分 + + uint64_t decimal = integer %tmp; // 提取小数部分 + std::cout<< "float_limit " << in<< " "<< integer << " "<< decimal << " "<< tmp <,int,int> process([](int p) -> int{ return 20; },result,150); - while(process.Finish() == false){ + while(process.Finish() == false) { } std::cout<