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
c40753ed
Commit
c40753ed
authored
Nov 06, 2023
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改日志打印功能,打印更加详细的日志
parent
6cb8a9a3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
0 deletions
+10
-0
CalcHelper.java
...src/main/java/com/yanzuoguang/util/helper/CalcHelper.java
+6
-0
TestCalc.java
yzg-util-base/src/test/java/helper/TestCalc.java
+4
-0
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/CalcHelper.java
View file @
c40753ed
...
...
@@ -208,6 +208,9 @@ public class CalcHelper {
if
(
scale
<
0
)
{
throw
new
IllegalArgumentException
(
"The scale must be a positive integer or zero"
);
}
if
(
d1
==
0
)
{
return
0
;
}
BigDecimal
b1
=
new
BigDecimal
(
Double
.
toString
(
d1
));
BigDecimal
b2
=
new
BigDecimal
(
Double
.
toString
(
d2
));
return
b1
.
divide
(
b2
,
scale
,
RoundingMode
.
HALF_UP
).
doubleValue
();
...
...
@@ -233,6 +236,9 @@ public class CalcHelper {
* @return 结果
*/
public
static
double
divList
(
double
d1
,
double
...
d2
)
{
if
(
d1
==
0
)
{
return
0
;
}
double
ret
=
d1
;
for
(
double
item
:
d2
)
{
ret
=
div
(
ret
,
item
);
...
...
yzg-util-base/src/test/java/helper/TestCalc.java
View file @
c40753ed
...
...
@@ -36,6 +36,10 @@ public class TestCalc {
CalcHelper
.
mulList
(
d1
,
d2
,
0.5
);
CalcHelper
.
divList
(
d1
,
d2
,
0.5
);
CalcHelper
.
divList
(
0
,
0
,
0.5
);
CalcHelper
.
div
(
0
,
0
);
CalcHelper
.
divDouble
(
0
D
,
0
D
);
CalcHelper
.
addListDouble
((
Double
)
null
,
d2
,
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