From: hcj <1224667075@qq.com> Date: Wed, 9 Oct 2024 10:08:50 +0000 (+0800) Subject: 计算器修改,解决double计算精度不够,导致计算出现多余小数位,#963 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=8277d2756fafde139f410594d403575ded468361;p=mirrors%2FFD230.git 计算器修改,解决double计算精度不够,导致计算出现多余小数位,#963 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/calculator/src/CalculatorView.cpp b/code/sdk/application/wearable/fd230app/nativeui/calculator/src/CalculatorView.cpp index 53eba1b0b..24abc75ca 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/calculator/src/CalculatorView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/calculator/src/CalculatorView.cpp @@ -10,6 +10,8 @@ #include "calculator/include/CalculatorModel.h" #include "wearable_log.h" #include +#include +#include namespace OHOS { @@ -241,6 +243,10 @@ void CalculatorView::symbol_text_updata_buf(const char *buf) double number_float=strtod(text_buf,NULL); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%lf %s",number_float,text_buf); + char new_buf_[64]={0}; + sprintf_s(new_buf_,64,"%.010lf",number_float); + number_float=strtod(new_buf_,NULL); + CalculatorModel::GetInstance()->number_push_stack(number_float); if( CalculatorModel::GetInstance()->get_stcak_size()>=2) @@ -362,13 +368,24 @@ void CalculatorView::symbol_text_updata_calculate_buf(const char *buf) char new_buf[64]={0}; const char*text_buf=number_string.c_str(); + double number_float=0; - double number_float=strtod(text_buf,NULL); - - CalculatorModel::GetInstance()->number_push_stack(number_float); + if(text_buf[0]>='0' && text_buf[0]<='9') + { + number_float=strtod(text_buf,NULL); + char new_buf_[64]={0}; + sprintf_s(new_buf_,64,"%.010lf",number_float); + number_float=strtod(new_buf_,NULL); + CalculatorModel::GetInstance()->number_push_stack(number_float); + } + number_float =CalculatorModel::GetInstance()->calculate_stack(); + char new_buf_[64]={0}; + sprintf_s(new_buf_,64,"%.010lf",number_float); + number_float=strtod(new_buf_,NULL); + double number_float_=number_float; int decimal_places = 0; double frac; diff --git a/code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp index 754e78a27..aafc868dc 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp @@ -118,6 +118,8 @@ static void DisableCallingTimer() } } +#include "dial_sos_c.h" + /* 状态复位 */ void StatusReset(void) { @@ -134,12 +136,15 @@ void StatusReset(void) CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourcePhone); DisshakeTimer(); + + // If the call is handling in the notification, the slice is not switched if (!CallerLogModel::GetInstance()->GetNotifyFlag()) { PhoneServiceScreenCtr(false); if(NativeAbility::GetInstance().GetCurSliceId() == VIEW_INCOMING_CALL) { + NativeAbility::GetInstance().Back_CountSlice_make_phone(); } @@ -541,6 +546,11 @@ static void NonWatchFinishHandle(int laststatus) if (GetCurrCallNum() == 0) { g_phoneStatus = PHONE_SINGLE_STATUS; } + + if(get_falg_SOS()) + { + sos_falg_add(); + } } static void WatchFinishHandle(void) @@ -567,6 +577,11 @@ static void WatchFinishHandle(void) WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "??????????????????????"); } g_phoneStatus = PHONE_SINGLE_STATUS; + + if(get_falg_SOS()) + { + sos_falg_add(); + } } void CAT1_ChangeStatusScreendisplay(int lastStatus) @@ -924,6 +939,8 @@ void CallerLogModel::SetWaitingStatus(bool status) void CallerLogModel::SetCallStatus(bool status) { callStatus = status; + if(status) + sos_falg_clean(); } bool CallerLogModel::GetCallStatus()