Logo
Explore Help
Register Sign In
Miko/LSL-PyOptimizer
1
0
Fork 0
You've already forked LSL-PyOptimizer
Code Issues Pull Requests Actions Packages Projects Releases Wiki Activity
Files
8d4750b6d0decf4bdcaeb4dd835ddef84d934b5d
LSL-PyOptimizer/unit_tests/regression.suite/parens.out

17 lines
281 B
Plaintext
Raw Normal View History

Fix parenthesization of unary minus The algorithm for adding parentheses around unary operators was not working properly. It converted a * (-b) * c into a * -b * c, which LSL handles as a * -(b * c). Fix and add test cases for that. One of the test cases shows an example where the difference matters: 0 * (-1e20) * 1e20 should result in 0.0, but if wrongly parenthesized, it gives NaN, because 1e20*1e20 gives infinity due to float overflow, and minus infinity times 0 is indeterminate. The addition of parentheses has been improved, but it still does not eliminate every redundant parenthesis. Also fix the horrendous typo of using "operands" where it should be "operators".
2019-05-04 23:07:45 +02:00
[ (-3) * 4
, -3 * 4
, -3 * 4
, ~-3 * 4
, -~3 * 4 | (~-3) * 4 & (-~3 * 4 | -~(3 * 4)) | - -3
, 3 * (~-4) * 5
, 3 * (~-4 * 5)
, 3 * (~-4) * 5
, 3 * (~-4) * 5
, 3 * (~-4 * 5)
, 3 * (-~4) * 5
, 3 * (-~4 * 5)
, 3 * (-~4 * 5)
, 3 * (-~(4 * 5))
, 0 * (-1e20) * 1e20
, 0 * (-1e20 * 1e20)
]
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.25.3 Page: 963ms Template: 9ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API