add two patches for respecting commits

Signed-off-by: IO-23 Oleh Shmuliar <hasslesstech@tutanota.com>
This commit is contained in:
ІО-23 Шмуляр Олег 2024-10-07 19:07:36 +03:00
parent b7e7566c43
commit 7c00e575e0
2 changed files with 80 additions and 0 deletions

View File

@ -0,0 +1,31 @@
From 465635efbdfcf7f23d6c45314183b6dbd24c5846 Mon Sep 17 00:00:00 2001
From: Sergii Piatakov <sergii.piatakov@globallogic.com>
Date: Thu, 15 Nov 2018 15:28:04 +0200
Subject: [PATCH 1/2] fix truncation error
To convert float to integer the truncation is performed, but the
rounding is expected.
Test: Add (4.9, 4.9) should return 10.
Signed-off-by: Sergii Piatakov <sergii.piatakov@globallogic.com>
Signed-off-by: IO-23 Oleh Shmuliar <hasslesstech@tutanota.com>
---
calculator.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/calculator.cpp b/calculator.cpp
index b91afea..d93e35b 100644
--- a/calculator.cpp
+++ b/calculator.cpp
@@ -2,7 +2,7 @@
int Calculator::Add (double a, double b)
{
- return a + b;
+ return a + b + 0.5;
}
int Calculator::Sub (double a, double b)
--
2.39.5

View File

@ -0,0 +1,49 @@
From 53143e5d9ebdab0ea06205b9e2c2dbf2a6d0b8ca Mon Sep 17 00:00:00 2001
From: Sergii Piatakov <sergii.piatakov@globallogic.com>
Date: Thu, 15 Nov 2018 15:26:35 +0200
Subject: [PATCH 2/2] formatting: use tabs instead of spaces
Signed-off-by: Sergii Piatakov <sergii.piatakov@globallogic.com>
Signed-off-by: IO-23 Oleh Shmuliar <hasslesstech@tutanota.com>
---
calculator.cpp | 4 ++--
calculator.h | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/calculator.cpp b/calculator.cpp
index d93e35b..f323e14 100644
--- a/calculator.cpp
+++ b/calculator.cpp
@@ -2,10 +2,10 @@
int Calculator::Add (double a, double b)
{
- return a + b + 0.5;
+ return a + b;
}
int Calculator::Sub (double a, double b)
{
- return Add (a, -b);
+ return Add (a, -b);
}
diff --git a/calculator.h b/calculator.h
index 3740907..d59d596 100644
--- a/calculator.h
+++ b/calculator.h
@@ -3,9 +3,9 @@
class Calculator
{
- public:
- int Add (double, double);
- int Sub (double, double);
+ public:
+ int Add (double, double);
+ int Sub (double, double);
};
#endif//CALCULATOR_H
--
2.39.5