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

Numeric comparisons with float32 values are not currently possible #8

Open
chrusty opened this issue Sep 8, 2021 · 2 comments
Open
Labels
bug Something isn't working

Comments

@chrusty
Copy link
Collaborator

chrusty commented Sep 8, 2021

We now attempt to assert/cast numeric values to float64 to allow comparison with number-based rollour strategies (which come from the server as JSON Float64).

This works fine for all types except float32 (which loses some precision in the conversion).

I'm sure there is a solution to this but for now we want to get going with the more accepting numeric conversion code.

@chrusty chrusty added the bug Something isn't working label Sep 8, 2021
@srkiNZ84
Copy link

srkiNZ84 commented Sep 8, 2021

How much precision do you need?

func roughlyEqualFloat64(a, b float64) bool {
    const equalityThreshold = 1e-7
    return math.Abs(a-b) < equalityThreshold
}

@chrusty
Copy link
Collaborator Author

chrusty commented Sep 8, 2021

It's not even only about equality... > / <=, =, >=, > too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants