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

EJsonRuntimeCompare is actually a EJsonRuntimeCompareNegative #144

Open
pkel opened this issue Aug 20, 2020 · 0 comments
Open

EJsonRuntimeCompare is actually a EJsonRuntimeCompareNegative #144

pkel opened this issue Aug 20, 2020 · 0 comments

Comments

@pkel
Copy link
Collaborator

pkel commented Aug 20, 2020

When translating Imp to Webassembly, I stumbled upon a small oddity in EJsonRuntimeOperators.v.

Section Evaluation.
...
      | EJsonRuntimeCompare =>
        apply_binary
          (fun d1 d2 =>
             match d1, d2 with
             | ejnumber n1, ejnumber n2 =>
               if float_lt n1 n2
               then
                 Some (ejnumber float_one)
               else if float_gt n1 n2
                    then
                      Some (ejnumber float_neg_one)
                    else
                      Some (ejnumber float_zero)   
...

From reading the eval, it seems that EJsonRuntimeCompare a b returns sign(b - a). The usual interpretation is sign(a - b) (ARM, OCaml).

Not sure whether this is worth fixing. It certainly doesn't matter for the verified parts.

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

1 participant