Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
utils
Overview
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
golang kittool
utils
Commits
999d400f
Commit
999d400f
authored
Mar 25, 2022
by
feidy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
string float64 int utils
parent
0c4b51e8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
3 deletions
+18
-3
strconv.go
strconv.go
+18
-3
No files found.
strconv.go
View file @
999d400f
package
utils
import
"strconv"
import
(
"fmt"
"strconv"
)
// int to string
func
IntToString
(
a
int
)
string
{
return
strconv
.
Itoa
(
a
)
}
func
Float64ToString
(
a
float64
)
string
{
return
strconv
.
FormatFloat
(
a
,
'E'
,
-
1
,
64
)
// float64 to string
func
Float64ToString
(
a
float64
,
point
int
)
string
{
a
=
FloatRound
(
a
,
point
)
return
strconv
.
FormatFloat
(
a
,
'f'
,
-
1
,
64
)
}
// string to int
func
StringToInt
(
s
string
)
int
{
i
,
_
:=
strconv
.
Atoi
(
s
)
return
i
}
// string to float64
func
StringToFloat64
(
s
string
)
float64
{
f
,
_
:=
strconv
.
ParseFloat
(
s
,
64
)
return
f
}
// float round point
func
FloatRound
(
f
float64
,
n
int
)
float64
{
format
:=
"%."
+
strconv
.
Itoa
(
n
)
+
"f"
res
,
_
:=
strconv
.
ParseFloat
(
fmt
.
Sprintf
(
format
,
f
),
64
)
return
res
}
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