File tree 2 files changed +13
-13
lines changed
2 files changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -97,30 +97,26 @@ func (x *BigInt) MaybeInt() Object {
97
97
return i
98
98
}
99
99
100
- // Truncates to go int64
100
+ // Truncates to go int
101
101
//
102
- // If it is outside the range of an go int64 it will return an error
103
- func (x * BigInt ) GoInt () (int64 , error ) {
102
+ // If it is outside the range of an go int it will return an error
103
+ func (x * BigInt ) GoInt () (int , error ) {
104
104
z , err := x .Int ()
105
105
if err != nil {
106
106
return 0 , err
107
107
}
108
- return int64 ( z ), nil
108
+ return z . GoInt ()
109
109
}
110
110
111
- // Truncates to go int
111
+ // Truncates to go int64
112
112
//
113
- // If it is outside the range of an go int it will return an error
114
- func (x * BigInt ) GoInt64 () (int , error ) {
113
+ // If it is outside the range of an go int64 it will return an error
114
+ func (x * BigInt ) GoInt64 () (int64 , error ) {
115
115
z , err := x .Int ()
116
116
if err != nil {
117
- return 0 , overflowErrorGo
118
- }
119
- r := int (z )
120
- if Int (r ) != z {
121
- return 0 , overflowErrorGo
117
+ return 0 , err
122
118
}
123
- return int ( r ), nil
119
+ return int64 ( z ), nil
124
120
}
125
121
126
122
// Frexp produces frac and exp such that a ~= frac × 2**exp
@@ -589,3 +585,5 @@ var _ conversionBetweenTypes = (*BigInt)(nil)
589
585
var _ I__bool__ = (* BigInt )(nil )
590
586
var _ I__index__ = (* BigInt )(nil )
591
587
var _ richComparison = (* BigInt )(nil )
588
+ var _ IGoInt = (* BigInt )(nil )
589
+ var _ IGoInt64 = (* BigInt )(nil )
Original file line number Diff line number Diff line change @@ -712,3 +712,5 @@ var _ conversionBetweenTypes = Int(0)
712
712
var _ I__bool__ = Int (0 )
713
713
var _ I__index__ = Int (0 )
714
714
var _ richComparison = Int (0 )
715
+ var _ IGoInt = Int (0 )
716
+ var _ IGoInt64 = Int (0 )
You can’t perform that action at this time.
0 commit comments