Rewrite Mono float to string conversion; fix llDumpList2String
llDumpList2String has changed its behaviour with respect to minus zero. Now it converts -0.0 to a string without the minus sign. While testing this, we noticed several mismatches in the float to string conversions; the existing routine did not properly convert some values because as we discovered later, it is subject to double rounding; one of them is the built-in round-to-nearest-or-even while getting the first 7 significant digits, and the other is just an increment when the digit is a 5 or more, so round to nearest, ties away from zero, and is performed on the digit past the five or six visible digits that LSL shows. The new code is a tad easier to understand and more robust. A first variant of the new code is left commented out for history's sake, and will be removed in the next commit.
This commit is contained in:
37
unit_tests/expr.suite/dumplist2string.out
Normal file
37
unit_tests/expr.suite/dumplist2string.out
Normal file
@@ -0,0 +1,37 @@
|
||||
[ "String cast in various ways except DumpList2String"
|
||||
, "<-0.00000, 0.00000, 0.00000>"
|
||||
, "<-0.000000, 0.000000, 0.000000>"
|
||||
, "-0.000000"
|
||||
, "<0.000000, 0.000000, 0.000000>"
|
||||
, "<0.00000, 0.00000, 0.00000>"
|
||||
, "0.000000"
|
||||
, "<0.000002, 0.000000, 0.000000>"
|
||||
, "<0.00000, 0.00000, 0.00000>"
|
||||
, "0.000002"
|
||||
, "<0.000003, 0.000000, 0.000000>"
|
||||
, "<0.00000, 0.00000, 0.00000>"
|
||||
, "0.000003"
|
||||
, "0.000003"
|
||||
, "<100000000000.000000, 0.000000, 0.000000>"
|
||||
, "<100000000000.00000, 0.00000, 0.00000>"
|
||||
, "100000000000.000000"
|
||||
, "100000000000.000000"
|
||||
, "<-0.000000, 0.000000, 0.000000>"
|
||||
, "<100000000000.000000, 0.000000, 0.000000>"
|
||||
, "<-0.000000, 0.000000, 0.000000>"
|
||||
, "<99999997952.000000, 0.000000, 0.000000>"
|
||||
, "DumpList2String:"
|
||||
, "<0.000000, 0.000000, 0.000000, 0.000000>"
|
||||
, "<0.000000, 0.000000, 0.000000, 0.000000>"
|
||||
, "0.000000"
|
||||
, "<0.000001, 0.000000, 0.000000>"
|
||||
, "<-0.000001, 0.000000, 0.000000>"
|
||||
, "<0.000000, 0.000000, 0.000000>"
|
||||
, "<0.000000, 0.000000, 0.000000>"
|
||||
, "<0.000002, 0.000000, 0.000000>"
|
||||
, "<-0.000002, 0.000000, 0.000000>"
|
||||
, "<0.000003, 0.000000, 0.000000>"
|
||||
, "<-0.000003, 0.000000, 0.000000>"
|
||||
, "100000000000.000000"
|
||||
, "------"
|
||||
]
|
||||
Reference in New Issue
Block a user