Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
f4babf69
Commit
f4babf69
authored
Jan 15, 2009
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- missed a few identifiers
R=r OCL=22864 CL=22864
parent
364a8520
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
13 deletions
+13
-13
bignum.go
src/lib/bignum.go
+13
-13
No files found.
src/lib/bignum.go
View file @
f4babf69
...
...
@@ -86,7 +86,7 @@ func assert(p bool) {
}
func
I
sSmall
(
x
Digit
)
bool
{
func
i
sSmall
(
x
Digit
)
bool
{
return
x
<
1
<<
_LogH
;
}
...
...
@@ -114,10 +114,10 @@ export func Dump(x []Digit) {
export
type
Natural
[]
Digit
;
var
(
N
atZero
Natural
=
Natural
{};
N
atOne
Natural
=
Natural
{
1
};
N
atTwo
Natural
=
Natural
{
2
};
N
atTen
Natural
=
Natural
{
10
};
n
atZero
Natural
=
Natural
{};
n
atOne
Natural
=
Natural
{
1
};
n
atTwo
Natural
=
Natural
{
2
};
n
atTen
Natural
=
Natural
{
10
};
)
...
...
@@ -125,10 +125,10 @@ var (
export
func
Nat
(
x
uint
)
Natural
{
switch
x
{
case
0
:
return
N
atZero
;
case
1
:
return
N
atOne
;
case
2
:
return
N
atTwo
;
case
10
:
return
N
atTen
;
case
0
:
return
n
atZero
;
case
1
:
return
n
atOne
;
case
2
:
return
n
atTwo
;
case
10
:
return
n
atTen
;
}
assert
(
Digit
(
x
)
<
_B
);
return
Natural
{
Digit
(
x
)};
...
...
@@ -608,7 +608,7 @@ func (x Natural) Log2() uint {
// Computes x = x div d in place (modifies x) for "small" d's.
// Returns updated x and x mod d.
func
divmod1
(
x
Natural
,
d
Digit
)
(
Natural
,
Digit
)
{
assert
(
0
<
d
&&
I
sSmall
(
d
-
1
));
assert
(
0
<
d
&&
i
sSmall
(
d
-
1
));
c
:=
Digit
(
0
);
for
i
:=
len
(
x
)
-
1
;
i
>=
0
;
i
--
{
...
...
@@ -679,8 +679,8 @@ func hexvalue(ch byte) uint {
// Computes x = x*d + c for "small" d's.
func
MulA
dd1
(
x
Natural
,
d
,
c
Digit
)
Natural
{
assert
(
IsSmall
(
d
-
1
)
&&
I
sSmall
(
c
));
func
mula
dd1
(
x
Natural
,
d
,
c
Digit
)
Natural
{
assert
(
isSmall
(
d
-
1
)
&&
i
sSmall
(
c
));
n
:=
len
(
x
);
z
:=
make
(
Natural
,
n
+
1
);
...
...
@@ -716,7 +716,7 @@ export func NatFromString(s string, base uint, slen *int) (Natural, uint) {
for
;
i
<
n
;
i
++
{
d
:=
hexvalue
(
s
[
i
]);
if
d
<
base
{
x
=
MulA
dd1
(
x
,
Digit
(
base
),
Digit
(
d
));
x
=
mula
dd1
(
x
,
Digit
(
base
),
Digit
(
d
));
}
else
{
break
;
}
...
...
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