val ~= val -- checks for NaN -> "We rely on the property that NaN is the only value that doesn't equal itself." (see http://lua-users.org/wiki/InfAndNanComparisons)
val >= math.huge
The first line could be easily transformed to val <> val. But is this legit or neccessary in Hollywood? Does NaN "exist" in Hollywood?
And what about the second line, checks agains infinity? Is that possible in Hollywood?
Thanks in advance!
Currently using: Hollywood 9 with Windows IDE and Hollywood 9 with Visual Studio Code and hw4vsc
Nice spot, this is currently not possible without going to greater pains because in comparison to Lua, Hollywood won't allow you to divide by zero. I have now added some functions which allow you to deal with all those things:
- New: Added RawDiv(); this does the same as Div() but doesn't check the divisor against 0 which allows you
to compute machine-specific representations of NaN and Inf by computing the results of 0/0 or 1/0
- New: Added IsNan(), IsInf(), and IsFinite() to math library to check a value against NaN, infinity, and
finiteness; also added the constants #NAN and #INF which contain the values of NaN and infinity; note
that due to the design of the parser, you cannot use #NAN as a literal value in your scripts; instead,
you have to use GetConstant("#NAN") to get the value of #NAN; #INF, on the other hand, can be used in
scripts; note: do not test for NaN by comparing the number with itself, expecting to get FALSE; this
won't work on all platforms; always use IsNan()
That was quick service. Was just about to ask if there be possibility to accept division by zero somehow, since that have been trouble so many times. Not really a big deal, since it is easy to fix, but slight annoyance every time.
Bugala wrote: ↑Mon Jul 22, 2019 6:00 pm
That was quick service. Was just about to ask if there be possibility to accept division by zero somehow, since that have been trouble so many times.
What's so funny about dividing by zero? Because it is forbidden?