shamblett / cbor

A CBOR implementation for Dart
MIT License
36 stars 16 forks source link

Bignum support #5

Closed shamblett closed 1 year ago

shamblett commented 6 years ago

Review the support for bignums in the package, at the moment these are supported only through tags

nailgilaziev commented 4 years ago

How to work with timestamps? If Map contains this: 6: 1579254859548 //milliseconds Bignums not supported message occurs in log.

shamblett commented 4 years ago

This looks like a bug, timestamps aren't bignums, that said things have moved on since this package was released, Dart does now support bignums, this area needs to be addressed.

shamblett commented 4 years ago

OK, bignum encoding support now added, there is a writeBignum encoder method that takes a BigInt and the writeInt method now automativcally encodes to a bignum if the integer value is large enough. Yo can now use the new builder classes to encode lists and maps with complex types, refer to issue 10.

Package re published at version 3.1.0

levifeldman commented 3 years ago

Hello, Gratitude for this library. It might just be on my computer but when trying to write an Int which is greater that 2^32 but less than 2^64 (Uint64) I see the class is using the final int two64-variable in the cbor_constants.dart-file, set to: pow(2,64). When i try to print(pow(2,64)) in a test file. i get the value: 0. This means that this library is coding ints that are greater than 2^32 and less than 2^64 as a BigNum in the stead of coding them as a Uint64.

shamblett commented 3 years ago

OK I'll have a look at this.

shamblett commented 3 years ago

I think I've got a solution for this, I've updated the unit tests and all is passing OK. I'll just do some final checks and hopefully re publish the package shortly.

levifeldman commented 3 years ago

Awesome.

shamblett commented 3 years ago

OK< I still have some concerns about negative bignum handling but I think your uint64 problem has been fixed. I've re published the package at version 4.0.2, please upgrade and re test.