Comments (2)
which works great, however, if the_dec is set to 10.10, it will convert to
the_dec: 10.1
loosing the precision in the process
I don't see how that's losing precision. In floating-point representation those are the same numbers, just different printing formats. If you're using console.log
, it just automatically prints number without trailing zeros, but you can always use console.log(num.toFixed(2))
if you want to print e.g. 2 fixed digits after the dot.
As a more general solution, if you want to convert decimal numbers to string instead of float, you can probably use something like serde_with::DisplayFromStr
.
from serde-wasm-bindgen.
I don't see how that's losing precision.
So it will end up within JS shortened anyway, understood. Thank you @RReverser
from serde-wasm-bindgen.
Related Issues (20)
- Internally tagged enumerations cannot deserialize byte buffers HOT 2
- `serde-wasm-bindgen` doesn't handle `serde(deny_unknown_fields)` properly HOT 3
- Error is not compatible with `Sync`/`Send`/`anyhow::Error` HOT 3
- as_bytes() does not work if self is an Array HOT 3
- Better interop between Tauri and serde-wasm-bindgen HOT 1
- Produce Object instead of Map when converting to JsValue HOT 2
- Hitting an unreachable! panic in serializing HOT 5
- Structures containing usize seems to create BigInt dependency in generated JavaScript bindings HOT 4
- json_compatible Deserializer HOT 1
- IntoWasmAbi HOT 3
- Preserved value de-serialization error HOT 8
- [improvement] Allow overriding default serializer used in to_value HOT 1
- `js_sys::Function` is not serialized correctly HOT 2
- Can't figure out how to get Option<js_sys::Date> to work when serializing to JS HOT 11
- #[serde(alias = "somename")] stopped working after 0.6 HOT 15
- More efficient serialization of struct HOT 1
- BTreeMap is failing to serialize? HOT 4
- Other JSValue compared to gloo-utils serde HOT 1
- Support JsValue serialization HOT 3
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 serde-wasm-bindgen.