ethereumjs / fixed-bn.js

a bn.js wrapper that constrains numbers to a fixed width
7 stars 9 forks source link

Modulo after operations #6

Closed s1na closed 1 week ago

s1na commented 5 years ago

FixedBN performs bound-checking in its constructor. Most of the operations return a new BN instance (not a FixedBN), and because they have not been overriden they wouldn't necessarily have the specified width. Does it make sense to override such operations to cast them to FixedBN and do a modulo afterwards if necessary? Or should users of the library take care of this?

axic commented 5 years ago

I think they should return a FixedBN instance. It should be possible to retrieve a BN instance out of a FixedBN instance.