Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
rym-util
Project
Overview
Details
Activity
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
zhengqiuyun
rym-util
Commits
a61293a2
Commit
a61293a2
authored
Feb 02, 2023
by
zhengqiuyun86
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
元与分的转换
parent
10d0724c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
0 deletions
+11
-0
FloatUtil.go
util/FloatUtil.go
+11
-0
No files found.
util/FloatUtil.go
View file @
a61293a2
package
util
import
(
"fmt"
"github.com/shopspring/decimal"
"strconv"
)
...
...
@@ -42,3 +43,13 @@ func DivideFloat64(a *float64, b *float64) *float64 {
r
,
_
:=
decimal
.
NewFromFloat
(
*
a
)
.
Div
(
decimal
.
NewFromFloat
(
*
b
))
.
Float64
()
return
&
r
}
func
yuanToFen
(
t
float64
)
int64
{
value
,
_
:=
strconv
.
ParseFloat
(
fmt
.
Sprintf
(
"%.2f"
,
*
MultiplyFloat64
(
&
t
,
Addr
(
float64
(
100
)))),
64
)
return
int64
(
value
+
0.5
)
}
func
fenToYuan
(
t
int64
)
float64
{
value
,
_
:=
strconv
.
ParseFloat
(
fmt
.
Sprintf
(
"%.2f"
,
*
DivideFloat64
(
Addr
(
float64
(
t
)),
Addr
(
float64
(
100
)))),
64
)
return
value
}
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