Comments (3)
The reason that this has not been implemented thus far is that the CBOR spec(RFC's 8949 and 7049) have an expectation that the most efficient form of encoding should be used if possible, for floats for instance from the spec -
If a protocol allows for IEEE floats, then additional
canonicalization rules might need to be added. One example rule
might be to have all floats start as a 64-bit float, then do a test
conversion to a 32-bit float; if the result is the same numeric
value, use the shorter value and repeat the process with a test
conversion to a 16-bit float. (This rule selects 16-bit float for
positive and negative Infinity as well.) Also, there are many
representations for NaN. If NaN is an allowed value, it must always
be represented as 0xf97e00.
That said I don't thinkmits unreasonable to allow users to chose how floats are encoded if they wish to do so.I'll have a look at this and see what can be done.
from cbor.
Ok you can now do this with floats -
final encoded = cbor.encode(CborFloat(0.0)..halfPrecision());
Similar for float and double precision. If the value supplied cannot be represented in the specified precision an ArgumentError is thrown.
Package re released at version 5.1.0
from cbor.
Forgot to add, if you dont specify a precision you get current behaviour i.e. best fit.
from cbor.
Related Issues (20)
- Nesting complex data HOT 7
- Converting object to an encodable object failed: _LinkedHashMap len:7 HOT 11
- Encoding of maps doesnt correctly handle Uint8Lists HOT 1
- Migrating to Null Safety HOT 3
- Support for packed CBOR HOT 2
- Uint8Buffer does not encode correctly HOT 7
- Uint8List in an array doesn't generate the CBOR byte string type HOT 2
- runtimeType String checking fails for web release builds HOT 3
- Bad state: No element HOT 2
- Bad state: No element - map tagetSize out of bounds HOT 5
- Changes to the API HOT 7
- Can't find 'simple.dart' HOT 13
- Please provide transition examples from 4.1 to 5.0 HOT 8
- encode int num 43008 decode another num -22528 HOT 4
- Add funding links to package HOT 1
- How does toJson decode Bytes List? HOT 4
- Compilation fails using inside flutter HOT 2
- Encoding complex maps HOT 1
- Invalid decoding of arrays HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cbor.