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

infinitesimal non-zero float values are rejected by the preprocessor #1150

Closed
thehowl opened this issue Sep 18, 2023 · 0 comments
Closed

infinitesimal non-zero float values are rejected by the preprocessor #1150

thehowl opened this issue Sep 18, 2023 · 0 comments
Assignees
Labels
🐞 bug Something isn't working 📦 🤖 gnovm Issues or PRs gnovm related

Comments

@thehowl
Copy link
Member

thehowl commented Sep 18, 2023

this comes from porting package math. Reproducible example:

package main

const (
	SmallestNonzeroFloat64 = 0x1p-1022 * 0x1p-52            // 4.9406564584124654417656879286822137236505980e-324
	DividedByTwo           = SmallestNonzeroFloat64 / 2
)

func main() {
	println(DividedByTwo)
}

In one of the tests, the following expression appears:

SmallestNonzeroFloat64 / 2

SmallestNonzeroFloat64 is what it says it is (precisely: 0x1p-1022 * 0x1p-52). Of course, being already the smallest, dividing it by 2 should yield 0. However, at preprocessing stage, the Gnovm rejects it entirely:

panic: cannot convert untyped bigdec to float64 -- too close to zero [recovered]
        panic: gno.land/r/GsgkK3Vq/all_test.gno:3282: cannot convert untyped bigdec to float64 -- too close to zero

goroutine 1 [running]:
github.com/gnolang/gno/gnovm/pkg/gnolang.Preprocess.func2.1()
        /home/howl/oc/gno2/gnovm/pkg/gnolang/preprocess.go:173 +0x46d
panic({0xbeb9a0, 0xf45fb0})
        /usr/lib/go/src/runtime/panic.go:890 +0x263
github.com/gnolang/gno/gnovm/pkg/gnolang.ConvertUntypedBigdecTo(0xc0084fd8f0, {0xc00b4797a8?}, {0xf521c8, 0xf44fb0})
        /home/howl/oc/gno2/gnovm/pkg/gnolang/values_conversions.go:1258 +0x585
@thehowl thehowl added 🐞 bug Something isn't working 📦 🤖 gnovm Issues or PRs gnovm related labels Sep 18, 2023
@thehowl thehowl added this to the 🚀 main.gno.land (required) milestone Sep 18, 2023
@ajnavarro ajnavarro self-assigned this Sep 20, 2023
thehowl added a commit that referenced this issue Oct 21, 2023
#1185)

Added a unit test and an integration test trying to reproduce #1150 

Avoid unhandled errors.

- [x] Added new tests, or not needed, or not feasible
- [x] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [x] Updated the official documentation or not needed
- [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [x] Added references to related issues and PRs
- [x] Provided any useful hints for running manual tests
- [x] Added new benchmarks to [generated
graphs](https://gnoland.github.io/benchmarks), if any. More info
[here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).

---------

Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
Co-authored-by: Morgan Bazalgette <morgan@morganbaz.com>
@thehowl thehowl closed this as completed Oct 21, 2023
thehowl added a commit to thehowl/gno that referenced this issue Oct 21, 2023
gnolang#1185)

Added a unit test and an integration test trying to reproduce gnolang#1150 

Avoid unhandled errors.

- [x] Added new tests, or not needed, or not feasible
- [x] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [x] Updated the official documentation or not needed
- [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [x] Added references to related issues and PRs
- [x] Provided any useful hints for running manual tests
- [x] Added new benchmarks to [generated
graphs](https://gnoland.github.io/benchmarks), if any. More info
[here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).

---------

Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
Co-authored-by: Morgan Bazalgette <morgan@morganbaz.com>
gfanton pushed a commit to gfanton/gno that referenced this issue Nov 9, 2023
gnolang#1185)

Added a unit test and an integration test trying to reproduce gnolang#1150 

Avoid unhandled errors.

- [x] Added new tests, or not needed, or not feasible
- [x] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [x] Updated the official documentation or not needed
- [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [x] Added references to related issues and PRs
- [x] Provided any useful hints for running manual tests
- [x] Added new benchmarks to [generated
graphs](https://gnoland.github.io/benchmarks), if any. More info
[here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).

---------

Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
Co-authored-by: Morgan Bazalgette <morgan@morganbaz.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working 📦 🤖 gnovm Issues or PRs gnovm related
Projects
Status: 🚀 Needed for Launch
Development

No branches or pull requests

2 participants