Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
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
张蕾
Geth-Modification
Commits
bf21549f
Commit
bf21549f
authored
Feb 17, 2017
by
Jeffrey Wilcke
Committed by
GitHub
Feb 17, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
common/math: "optimised" SafeMul and added comment on Exp (#3675)
parent
6f74fb96
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
2 deletions
+5
-2
exp.go
common/math/exp.go
+3
-0
integer.go
common/math/integer.go
+2
-2
No files found.
common/math/exp.go
View file @
bf21549f
...
...
@@ -27,6 +27,9 @@ const wordSize = 32 << (uint64(^big.Word(0)) >> 63)
// Exp implement exponentiation by squaring algorithm.
//
// Exp return a new variable; base and exponent must
// not be changed under any circumstance.
//
// Courtesy @karalabe and @chfast
func
Exp
(
base
,
exponent
*
big
.
Int
)
*
big
.
Int
{
result
:=
big
.
NewInt
(
1
)
...
...
common/math/integer.go
View file @
bf21549f
...
...
@@ -18,8 +18,8 @@ func SafeAdd(x, y uint64) (uint64, bool) {
// SafeMul returns multiplication result and whether overflow occurred.
func
SafeMul
(
x
,
y
uint64
)
(
uint64
,
bool
)
{
if
x
==
0
{
if
x
==
0
||
y
==
0
{
return
0
,
false
}
return
x
*
y
,
x
!=
0
&&
y
!=
0
&&
y
>
gmath
.
MaxUint64
/
x
return
x
*
y
,
y
>
gmath
.
MaxUint64
/
x
}
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