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
433ac8e5
Commit
433ac8e5
authored
Jun 26, 2008
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- a couple of fixes for integer.go
- added pkg dir SVN=124991
parent
bcfd31f0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
3 deletions
+27
-3
bug058.go
test/bugs/bug058.go
+3
-1
integer.go
test/integer.go
+24
-2
No files found.
test/bugs/bug058.go
View file @
433ac8e5
...
...
@@ -10,7 +10,9 @@ type Box struct {};
var
m
map
[
string
]
*
Box
;
func
main
()
{
m
[
"foo"
]
=
nil
;
s
:=
"foo"
;
var
x
*
Box
=
nil
;
m
[
s
]
=
x
;
}
/*
...
...
test/integer.go
View file @
433ac8e5
...
...
@@ -415,7 +415,7 @@ func copy(x Value) Value {
z
:=
alloc
(
xl
+
1
);
// add space for one extra digit
for
i
:=
0
;
i
<
xl
;
i
++
{
z
[
i
+
H
]
=
x
[
i
+
H
];
}
set_len
(
z
,
xl
);
set_len
(
z
,
int
(
x
[
0
]));
// don't loose sign!
return
z
;
}
...
...
@@ -569,7 +569,14 @@ func (x Integer) xor (y Integer) Integer {
// Comparisons
func
(
x
Integer
)
cmp
(
y
Integer
)
int
{
return
0
;
// do better then this
d
:=
x
.
sub
(
y
);
switch
{
case
sign
(
d
.
val
)
:
return
-
1
;
case
zero
(
d
.
val
)
:
return
0
;
default
:
return
+
1
;
}
CHECK
(
false
);
// unreachable
}
...
...
@@ -616,3 +623,18 @@ func (x Integer) ToString() string {
return
tostring
(
x
.
val
);
}
func
(
x
Integer
)
ToInt
()
int
{
v
:=
x
.
val
;
if
len_
(
v
)
<=
1
{
if
zero
(
v
)
{
return
0
;
}
i
:=
int
(
v
[
0
+
H
]);
if
sign
(
v
)
{
i
=
-
i
;
// incorrect for smallest int
}
return
i
;
}
panic
"integer too large"
;
}
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