@@ -34,13 +34,12 @@ func limitUnsigned256(x *Number) *Number {
3434func limitSigned256 (x * Number ) * Number {
3535 if x .num .Cmp (tt255 ) < 0 {
3636 return x
37- } else {
38- x .num .Sub (x .num , tt256 )
39- return x
4037 }
38+ x .num .Sub (x .num , tt256 )
39+ return x
4140}
4241
43- // Number function
42+ // Initialiser is a Number function
4443type Initialiser func (n int64 ) * Number
4544
4645// A Number represents a generic integer with a bounding function limiter. Limit is called after each operations
@@ -51,79 +50,79 @@ type Number struct {
5150 limit func (n * Number ) * Number
5251}
5352
54- // Returns a new initialiser for a new *Number without having to expose certain fields
53+ // NewInitialiser returns a new initialiser for a new *Number without having to expose certain fields
5554func NewInitialiser (limiter func (* Number ) * Number ) Initialiser {
5655 return func (n int64 ) * Number {
5756 return & Number {big .NewInt (n ), limiter }
5857 }
5958}
6059
61- // Return a Number with a UNSIGNED limiter up to 256 bits
60+ // Uint256 returns a Number with a UNSIGNED limiter up to 256 bits
6261func Uint256 (n int64 ) * Number {
6362 return & Number {big .NewInt (n ), limitUnsigned256 }
6463}
6564
66- // Return a Number with a SIGNED limiter up to 256 bits
65+ // Int256 returns Number with a SIGNED limiter up to 256 bits
6766func Int256 (n int64 ) * Number {
6867 return & Number {big .NewInt (n ), limitSigned256 }
6968}
7069
71- // Returns a Number with a SIGNED unlimited size
70+ // Big returns a Number with a SIGNED unlimited size
7271func Big (n int64 ) * Number {
7372 return & Number {big .NewInt (n ), func (x * Number ) * Number { return x }}
7473}
7574
76- // Sets i to sum of x+y
75+ // Add sets i to sum of x+y
7776func (i * Number ) Add (x , y * Number ) * Number {
7877 i .num .Add (x .num , y .num )
7978 return i .limit (i )
8079}
8180
82- // Sets i to difference of x-y
81+ // Sub sets i to difference of x-y
8382func (i * Number ) Sub (x , y * Number ) * Number {
8483 i .num .Sub (x .num , y .num )
8584 return i .limit (i )
8685}
8786
88- // Sets i to product of x*y
87+ // Mul sets i to product of x*y
8988func (i * Number ) Mul (x , y * Number ) * Number {
9089 i .num .Mul (x .num , y .num )
9190 return i .limit (i )
9291}
9392
94- // Sets i to the quotient prodject of x/y
93+ // Div sets i to the quotient prodject of x/y
9594func (i * Number ) Div (x , y * Number ) * Number {
9695 i .num .Div (x .num , y .num )
9796 return i .limit (i )
9897}
9998
100- // Sets i to x % y
99+ // Mod sets i to x % y
101100func (i * Number ) Mod (x , y * Number ) * Number {
102101 i .num .Mod (x .num , y .num )
103102 return i .limit (i )
104103}
105104
106- // Sets i to x << s
105+ // Lsh sets i to x << s
107106func (i * Number ) Lsh (x * Number , s uint ) * Number {
108107 i .num .Lsh (x .num , s )
109108 return i .limit (i )
110109}
111110
112- // Sets i to x^y
111+ // Pow sets i to x^y
113112func (i * Number ) Pow (x , y * Number ) * Number {
114113 i .num .Exp (x .num , y .num , big .NewInt (0 ))
115114 return i .limit (i )
116115}
117116
118117// Setters
119118
120- // Set x to i
119+ // Set sets x to i
121120func (i * Number ) Set (x * Number ) * Number {
122121 i .num .Set (x .num )
123122 return i .limit (i )
124123}
125124
126- // Set x bytes to i
125+ // SetBytes sets x bytes to i
127126func (i * Number ) SetBytes (x []byte ) * Number {
128127 i .num .SetBytes (x )
129128 return i .limit (i )
@@ -140,12 +139,12 @@ func (i *Number) Cmp(x *Number) int {
140139
141140// Getters
142141
143- // Returns the string representation of i
142+ // String returns the string representation of i
144143func (i * Number ) String () string {
145144 return i .num .String ()
146145}
147146
148- // Returns the byte representation of i
147+ // Bytes returns the byte representation of i
149148func (i * Number ) Bytes () []byte {
150149 return i .num .Bytes ()
151150}
@@ -160,17 +159,17 @@ func (i *Number) Int64() int64 {
160159 return i .num .Int64 ()
161160}
162161
163- // Returns the signed version of i
162+ // Int256 returns the signed version of i
164163func (i * Number ) Int256 () * Number {
165164 return Int (0 ).Set (i )
166165}
167166
168- // Returns the unsigned version of i
167+ // Uint256 returns the unsigned version of i
169168func (i * Number ) Uint256 () * Number {
170169 return Uint (0 ).Set (i )
171170}
172171
173- // Returns the index of the first bit that's set to 1
172+ // FirstBitSet returns the index of the first bit that's set to 1
174173func (i * Number ) FirstBitSet () int {
175174 for j := 0 ; j < i .num .BitLen (); j ++ {
176175 if i .num .Bit (j ) > 0 {
0 commit comments