It's a well-known problem.
For your specific use case, we can walk-around like this:
- You can use
fixed
crate to process real numbers, including parsing, to string, and arithmetic ops
- To parse the json, you cannot use
serde_json
because it always introduce float points. Theoretically serde_json_core
can be used, as long as you don't touch any type with float points. However, the API value is actually a float point, I don't know if you can give it a fixed point type or write your own serde parser.
- In the worst case, you can try to manually parse the string (thinking about string processing in C), and combine with
fixed
to further work with real numbers
An additional information. We have SideVM without all these annoying limitations. It supports float points, std, sockets, and even async runtime (AsyncStd, partial tokio, Hyper, etc). The only caveat is that it's too powerful that we still haven't implement any resource rate-limiter to ensure the fair usage. So it's kinda like the parachain in 2019... We do have some ideas, and hopefully we can release it as a discussion to the public soon.