You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
func (f *fieldVal) AddInt(ui uint) *fieldVal {
// Since the field representation intentionally provides overflow bits,
// it's ok to use carryless addition as the carry bit is safely part of
// the word and will be normalized out.
f.n[0] += uint32(ui)
return f
}
I think it is not really safe here. If ui is uint32::MAX and f.n[0] is 1, what will happen?
BTW, it is not proper here to cast uint to uint32 (on 64bit syste, uint is uint64).
The text was updated successfully, but these errors were encountered:
It is documented that that function is intended for usage with small numbers:
// AddInt adds the passed integer to the existing field value and stores the// result in f. This is a convenience function since it is fairly common to// perform some arithemetic with small native integers.//// The field value is returned to support chaining. This enables syntax like:// f.AddInt(1).Add(f2) so that f = f + 1 + f2.
I think it is not really safe here. If ui is uint32::MAX and f.n[0] is 1, what will happen?
BTW, it is not proper here to cast uint to uint32 (on 64bit syste, uint is uint64).
The text was updated successfully, but these errors were encountered: