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
17596948
Commit
17596948
authored
Nov 04, 2008
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get rid of bignum leftovers
R=r OCL=18475 CL=18475
parent
3200b06b
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
0 additions
and
173 deletions
+0
-173
Makefile
usr/gri/bignum/Makefile
+0
-20
integer.go
usr/gri/bignum/integer.go
+0
-0
make.bash
usr/gri/bignum/make.bash
+0
-16
test_integer.go
usr/gri/bignum/test_integer.go
+0
-137
No files found.
usr/gri/bignum/Makefile
deleted
100644 → 0
View file @
3200b06b
# Copyright 2009 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
G
=
6g
L
=
6l
bignum_test
:
bignum_test.6
$(L)
-o
bignum_test bignum_test.6
test
:
bignum_test
./bignum_test
clean
:
rm
-f
bignum_test
*
.6
*
~
bignum_test.6
:
bignum.6
%.6
:
%.go
$(G)
$(F)
$<
usr/gri/bignum/integer.go
deleted
100755 → 0
View file @
3200b06b
This diff is collapsed.
Click to expand it.
usr/gri/bignum/make.bash
deleted
100644 → 0
View file @
3200b06b
# Copyright 2009 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
#!/bin/bash
set
-e
# clean
rm
-f
*
.6 6.out test_integer
# integer package
6g integer.go
6g test_integer.go
6l
-o
test_integer integer.6 test_integer.6
./test_integer
usr/gri/bignum/test_integer.go
deleted
100644 → 0
View file @
3200b06b
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
main
import
Integer
"integer"
type
Int
Integer
.
Integer
;
const
(
sa
=
"991"
;
sb
=
"2432902008176640000"
;
// 20!
sc
=
"93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000"
;
// 100!
)
var
(
m
,
z
,
p
,
a
,
b
,
c
,
a_a
,
a_b
,
a_c
,
b_b
,
b_c
,
c_c
,
a_b_c
Int
)
func
CHECK
(
msg
string
,
p
bool
)
{
if
!
p
{
panic
(
"CHECK failed: "
,
msg
,
"
\n
"
);
}
}
func
Init
()
{
m
=
Integer
.
FromInt
(
-
1
);
z
=
Integer
.
FromInt
(
0
);
p
=
Integer
.
FromInt
(
1
);
a
=
Integer
.
FromString
(
sa
);
b
=
Integer
.
FromString
(
sb
);
c
=
Integer
.
FromString
(
sc
);
a_a
=
Integer
.
FromInt
(
991
+
991
);
a_b
=
Integer
.
FromString
(
"2432902008176640991"
);
a_c
=
Integer
.
FromString
(
"93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000991"
);
}
func
N991
()
string
{
return
"991"
}
func
TestConv
()
{
print
(
"TestConv
\n
"
);
CHECK
(
"TC1"
,
a
.
eql
(
Integer
.
FromInt
(
991
)));
CHECK
(
"TC2"
,
b
.
eql
(
Integer
.
Fact
(
20
)));
CHECK
(
"TC3"
,
c
.
eql
(
Integer
.
Fact
(
100
)));
CHECK
(
"TC4"
,
a
.
ToString
()
==
sa
);
CHECK
(
"TC5"
,
b
.
ToString
()
==
sb
);
CHECK
(
"TC6"
,
c
.
ToString
()
==
sc
);
// also tested much via TestFact
}
func
TestAdd
()
{
print
(
"TestAdd
\n
"
);
CHECK
(
"TA1"
,
z
.
add
(
z
)
.
eql
(
z
));
CHECK
(
"TA2"
,
a
.
add
(
z
)
.
eql
(
a
));
CHECK
(
"TA3"
,
z
.
add
(
a
)
.
eql
(
a
));
CHECK
(
"TA4"
,
c
.
add
(
z
)
.
eql
(
c
));
CHECK
(
"TA5"
,
z
.
add
(
c
)
.
eql
(
c
));
CHECK
(
"TA6"
,
m
.
add
(
p
)
.
eql
(
z
));
CHECK
(
"TA7"
,
a
.
add
(
a
)
.
eql
(
a_a
));
CHECK
(
"TA8"
,
a
.
add
(
b
)
.
eql
(
a_b
));
CHECK
(
"TA9"
,
a
.
add
(
c
)
.
eql
(
a_c
));
// needs more
}
func
TestSub
()
{
print
(
"TestSub
\n
"
);
CHECK
(
"TS1"
,
z
.
sub
(
z
)
.
eql
(
z
));
CHECK
(
"TS2"
,
a
.
sub
(
z
)
.
eql
(
a
));
CHECK
(
"TS3"
,
z
.
sub
(
a
)
.
eql
(
a
.
neg
()));
CHECK
(
"TS4"
,
c
.
sub
(
z
)
.
eql
(
c
));
CHECK
(
"TS5"
,
z
.
sub
(
c
)
.
eql
(
c
.
neg
()));
CHECK
(
"TS6"
,
p
.
sub
(
m
)
.
eql
(
p
.
add
(
p
)));
CHECK
(
"TS7"
,
a
.
sub
(
a
)
.
eql
(
z
));
// needs more
}
func
TestMul
()
{
print
(
"TestMul
\n
"
);
// tested much via TestFact for now
}
func
TestDiv
()
{
print
(
"TestDiv
\n
"
);
// no div implemented yet
}
func
TestMod
()
{
print
(
"TestMod
\n
"
);
// no mod implemented yet
}
func
TestFact
()
{
print
(
"TestFact
\n
"
);
for
n
:=
990
;
n
<
1010
;
n
++
{
f
:=
Integer
.
Fact
(
n
);
CHECK
(
"TF"
,
Integer
.
FromString
(
f
.
ToString
())
.
eql
(
f
));
}
}
func
main
()
{
Init
();
TestConv
();
TestAdd
();
TestSub
();
TestMul
();
TestDiv
();
TestMod
();
TestFact
();
print
(
"PASSED
\n
"
);
}
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