bigints
bigints copied to clipboard
Add toBytes proc
- Export
isNegativeandisZerobecause it is easier to export here than to reimplement downstream. - Add
toBytesproc for serializing. This is used by the CBOR package. Also easier to implement here than downstream. - Rename the tests/tliterals.nim to comply with Nimble standards. Not all tools are using
nimble testfor testing, some rely only on Nimble standards.
Thanks for your contribution! The algorithm looks fine to me.
– Could you add tests for the toBytes procedure?
– Could you add the corresponding fromBytes procedure?
I believe that the tliterals was renamed literals as to not run these tests. You might want to check the log for this specific file.
I pushed a test for toBytes. I will push fromBytes soon.
Now with fromBytes and a test of random serializations.
I'm against exporting isNegative and isZero. I think the better solution would be to support comparing with ints, then we can just use < 0 and == 0 (see #132).
I'm against exporting
isNegativeandisZero. I think the better solution would be to support comparing withints, then we can just use< 0and== 0(see #132).
That would be adding more code to do something that is already implemented.
I'm against exporting
isNegativeandisZero. I think the better solution would be to support comparing withints, then we can just use< 0and== 0(see #132).That would be adding more code to do something that is already implemented.
Yes, but it's also uglier imo.
I am for exporting isNegative only and implement equality with integers. Comparing with integers and fetching a boolean flag are two different things.
Note that isNegative really means "is less than or equal to zero", as 0 can also have isNegative set.
Thanks for the reminder.