计算器修改,解决double计算精度不够,导致计算出现多余小数位,#963
authorhcj <1224667075@qq.com>
Wed, 9 Oct 2024 10:08:50 +0000 (18:08 +0800)
committerhcj <1224667075@qq.com>
Wed, 9 Oct 2024 10:08:50 +0000 (18:08 +0800)
code/sdk/application/wearable/fd230app/nativeui/calculator/src/CalculatorView.cpp
code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp

index 53eba1b..24abc75 100644 (file)
@@ -10,6 +10,8 @@
 #include "calculator/include/CalculatorModel.h"
 #include "wearable_log.h"
 #include <math.h>
+#include <iostream>
+#include <iomanip>
 
 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;
index 754e78a..aafc868 100644 (file)
@@ -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()