Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
YZG
yzg-util
Commits
4dd3a28f
Commit
4dd3a28f
authored
Apr 21, 2023
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
表结构修改
parent
f59759fc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
9 deletions
+30
-9
CalcHelper.java
...src/main/java/com/yanzuoguang/util/helper/CalcHelper.java
+8
-8
TestCalc.java
yzg-util-base/src/test/java/helper/TestCalc.java
+22
-1
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/CalcHelper.java
View file @
4dd3a28f
...
@@ -60,8 +60,8 @@ public class CalcHelper {
...
@@ -60,8 +60,8 @@ public class CalcHelper {
*/
*/
public
static
double
addListDouble
(
Double
d1
,
Double
...
d2
)
{
public
static
double
addListDouble
(
Double
d1
,
Double
...
d2
)
{
double
ret
=
d1
;
double
ret
=
d1
;
for
(
d
ouble
item
:
d2
)
{
for
(
D
ouble
item
:
d2
)
{
ret
=
add
(
ret
,
item
);
ret
=
add
Double
(
ret
,
item
);
}
}
return
ret
;
return
ret
;
}
}
...
@@ -114,8 +114,8 @@ public class CalcHelper {
...
@@ -114,8 +114,8 @@ public class CalcHelper {
*/
*/
public
static
double
subListDouble
(
Double
d1
,
Double
...
d2
)
{
public
static
double
subListDouble
(
Double
d1
,
Double
...
d2
)
{
double
ret
=
d1
;
double
ret
=
d1
;
for
(
d
ouble
item
:
d2
)
{
for
(
D
ouble
item
:
d2
)
{
ret
=
sub
(
ret
,
item
);
ret
=
sub
Double
(
ret
,
item
);
}
}
return
ret
;
return
ret
;
}
}
...
@@ -168,8 +168,8 @@ public class CalcHelper {
...
@@ -168,8 +168,8 @@ public class CalcHelper {
*/
*/
public
static
double
mulListDouble
(
Double
d1
,
Double
...
d2
)
{
public
static
double
mulListDouble
(
Double
d1
,
Double
...
d2
)
{
double
ret
=
d1
;
double
ret
=
d1
;
for
(
d
ouble
item
:
d2
)
{
for
(
D
ouble
item
:
d2
)
{
ret
=
mul
(
ret
,
item
);
ret
=
mul
Double
(
ret
,
item
);
}
}
return
ret
;
return
ret
;
}
}
...
@@ -249,8 +249,8 @@ public class CalcHelper {
...
@@ -249,8 +249,8 @@ public class CalcHelper {
*/
*/
public
static
double
divListDouble
(
Double
d1
,
Double
...
d2
)
{
public
static
double
divListDouble
(
Double
d1
,
Double
...
d2
)
{
double
ret
=
d1
;
double
ret
=
d1
;
for
(
d
ouble
item
:
d2
)
{
for
(
D
ouble
item
:
d2
)
{
ret
=
div
(
ret
,
item
);
ret
=
div
Double
(
ret
,
item
);
}
}
return
ret
;
return
ret
;
}
}
...
...
yzg-util-base/src/test/java/helper/TestCalc.java
View file @
4dd3a28f
package
helper
;
package
helper
;
import
com.yanzuoguang.util.helper.CalcHelper
;
import
com.yanzuoguang.util.helper.CalcHelper
;
import
com.yanzuoguang.util.helper.RsaHelper
;
import
org.junit.Assert
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -18,4 +17,26 @@ public class TestCalc {
...
@@ -18,4 +17,26 @@ public class TestCalc {
double
d4
=
d1
+
d2
;
double
d4
=
d1
+
d2
;
Assert
.
assertFalse
(
CalcHelper
.
equals
(
d4
,
0.3
));
Assert
.
assertFalse
(
CalcHelper
.
equals
(
d4
,
0.3
));
}
}
@Test
public
void
test1
()
throws
Exception
{
double
d1
=
0.1
;
double
d2
=
0.2
;
double
d3
=
CalcHelper
.
addListDouble
(
d1
,
d2
,
null
);
Assert
.
assertTrue
(
CalcHelper
.
equals
(
d3
,
0.3
));
CalcHelper
.
subListDouble
(
d1
,
d2
,
null
);
CalcHelper
.
mulListDouble
(
d1
,
d2
,
null
);
CalcHelper
.
divListDouble
(
d1
,
d2
,
0.5
);
CalcHelper
.
addList
(
d1
,
d2
,
0.3
);
CalcHelper
.
subList
(
d1
,
d2
,
0.3
);
CalcHelper
.
mulList
(
d1
,
d2
,
0.5
);
CalcHelper
.
divList
(
d1
,
d2
,
0.5
);
double
d4
=
d1
+
d2
;
Assert
.
assertFalse
(
CalcHelper
.
equals
(
d4
,
0.3
));
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment