Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of Floats is not supported in CosmWasm #19

Closed
sashaduke opened this issue Jan 26, 2023 · 7 comments
Closed

Use of Floats is not supported in CosmWasm #19

sashaduke opened this issue Jan 26, 2023 · 7 comments

Comments

@sashaduke
Copy link

sashaduke commented Jan 26, 2023

The use of a Float32 type in src/utils/indices.rs results in the crate not compiling on CosmWasm's WASM VM.
A fix has been proposed on this pull request.

@matthiasgoergens
Copy link
Contributor

To be more precise WebAssembly supports floats just fine by itself, but Sasha has an application that only supports a subset of WASM that doesn't include floating point operations.

@sashaduke sashaduke changed the title Use of Floats is not supported in WASM Use of Floats is not supported in CosmWasm Jan 27, 2023
@matthiasgoergens
Copy link
Contributor

Also addressed in #16

@antouhou
Copy link
Owner

I've added a comment to #16. Although this does remove the use of the float, this makes this incompatible with the no-std. I'll try to come up with a way to do this without using floats and std. Being able to use this in the CosmWasm definitely an important feature. Thank you for the report!

@matthiasgoergens
Copy link
Contributor

Thanks for having a look.

You can always use a loop to count how many right shifts you need until the number turns to 0?

There was another PR with the same aim as mine that did something like this.

@sashaduke
Copy link
Author

sashaduke commented Feb 24, 2023

no_std compatibility can be maintained by using core::mem::sizeof instead of std::mem::sizeof

@antouhou
Copy link
Owner

Hi @matthiasgoergens @sashaduke! I've merged your PRs and added one additional check for no-std targets. The changes are included in v1.3.0. Thank you! Please close this issue if that works for you, or I'll close it myself in some time :)

Thank you!

@matthiasgoergens
Copy link
Contributor

Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants