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

Add Inf and NaN literals to the DSL #933

Merged
merged 5 commits into from
Feb 8, 2022
Merged

Add Inf and NaN literals to the DSL #933

merged 5 commits into from
Feb 8, 2022

Conversation

johnkerl
Copy link
Owner

@johnkerl johnkerl commented Feb 8, 2022

This is in support of #908

You can already get IEEE Inf and NaN in the DSL by 1/0 and 0/0, respectively. The change is that now you can refer to them by name.

Also note that NaN != NaN -- this is a general face of IEEE floating-point arithmetic, nothing to do with Miller. So, now (like other languages) Miller has an is_nan DSL function to check if something is the not-a-number value.

$ rlwrap mlr repl
Miller 6.0.0-dev REPL for darwin/amd64/go1.17
Docs: https://miller.readthedocs.io
Type ':h' or ':help' for online help; ':q' or ':quit' to quit.
[mlr] 1/0
+Inf
[mlr] 0/0
NaN

[mlr] 1/0 == Inf
true
[mlr] 0/0 == NaN
false
[mlr] is_nan(0/0)
true
[mlr] is_nan(NaN)
true

[mlr] ?is_nan
is_nan  (class=typing #args=1) True if the argument is the NaN (not-a-number) floating-point value. Note that NaN has the property that NaN != NaN, so you need 'is_nan(x)' rather than 'x == NaN'.

[mlr] log10(0)
-Inf
[mlr] log10(-2)
NaN
[mlr] is_nan(log10(-2))
true

@johnkerl johnkerl force-pushed the dsl-inf-nan branch 2 times, most recently from 66c6f75 to 469f397 Compare February 8, 2022 14:44
@johnkerl johnkerl merged commit d67868b into main Feb 8, 2022
@johnkerl johnkerl deleted the dsl-inf-nan branch February 8, 2022 14:58
@johnkerl johnkerl restored the dsl-inf-nan branch February 8, 2022 14:59
@johnkerl johnkerl deleted the dsl-inf-nan branch February 8, 2022 15:04
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

Successfully merging this pull request may close these issues.

1 participant