LSL-PyOptimizer/unit_tests/expr.suite/dumplist2string.lsl
Sei Lisa d2e64e25a6 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.
2022-05-17 22:28:49 +02:00

38 lines
No EOL
1.4 KiB
Text

// Change in behaviour for llDumpList2String
[ "String cast in various ways except DumpList2String"
, (string)<-0.0, 0, 0>
, (string)[<-0.0, 0, 0>]
, (string)[-0.0]
, (string)[<4.999999418942025e-07, 0, 0>]
, (string)<4.999999418942025e-07, 0, 0>
, (string)4.999999418942025e-07
, (string)[<1.4999999393694452e-06, 0, 0>]
, (string)<1.4999999393694452e-06, 0, 0>
, (string)1.4999999393694452e-06
, (string)[<2.499999936844688e-06, 0, 0>]
, (string)<2.499999936844688e-06, 0, 0>
, (string)[2.499999936844688e-06]
, (string)2.499999936844688e-06
, (string)[<1e11,0,0>]
, (string)<1e11,0,0>
, (string)[1e11]
, (string)1e11
, llList2String([<-0.0, 0, 0>], 0)
, llList2String([<1e11, 0, 0>], 0)
, llList2CSV([<-0.0, 0, 0>])
, llList2CSV([<1e11, 0, 0>])
, "DumpList2String:"
, llDumpList2String([<-0.0, -0.0, -0.0, -0.0>], "")
, llDumpList2String([<-1e-40, -1e-40, -1e-40, -1e-40>], "")
, llDumpList2String([-0.0], "")
, llDumpList2String([<5e-7, 0, 0>], "")
, llDumpList2String([<-5e-7, 0, 0>], "")
, llDumpList2String([<4.999999418942025e-07, 0, 0>], "")
, llDumpList2String([<-4.999999418942025e-07, 0, 0>], "")
, llDumpList2String([<1.4999999393694452e-06, 0, 0>], "")
, llDumpList2String([<-1.4999999393694452e-06, 0, 0>], "")
, llDumpList2String([<2.499999936844688e-06, 0, 0>], "")
, llDumpList2String([<-2.499999936844688e-06, 0, 0>], "")
, llDumpList2String([100000000000.000000], "")
, "------"
]