"EnTerr" wrote:
Nope?
I admire the creative though, got excited for a moment but seems 'twas too good to be true:
Ok.. hrmm.. I tested it with 1.0#, not 1.2345678987654321#. 1.0# gives much better results :P... even better than ?, for that matter.:?
BrightScript Debugger> d = 1.0# : for i=-5 to 15: dd = d*10#^i: ? i, dd, str(dd), fn(dd): end for
-5 1e-05 1e-05 1e-05
-4 0.0001 0.0001 0.0001
-3 0.001 0.001 0.001
-2 0.01 0.01 0.01
-1 0.1 0.1 0.1
0 1 1 1
1 10 10 10
2 100 100 100
3 1000 1000 1000
4 10000 10000 10000
5 100000 100000 100000
6 1000000 1000000 1000000
7 10000000 1e+07 10000000
8 100000000 1e+08 100000000
9 1000000000 1e+09 1000000000
10 10000000000 1e+10 10000000000
11 100000000000 1e+11 100000000000
12 1000000000000 1e+12 1000000000000
13 10000000000000 1e+13 10000000000000
14 1e+14 1e+14 100000000000000
15 1e+15 1e+15 1000000000000000
EDIT: Looks like 6 decimal places might be the limit for consistent results for fractions...
BrightScript Debugger> d = 1.123456# : for i=-5 to 20: dd# = d*10#^i: ? i, dd#, str(dd#), fn(dd#): end for
-5 1.123456e-05 1.123456e-05 1.12346e-05
-4 0.0001123456 0.0001123456 0.000112346
-3 0.001123456 0.001123456 0.00112346
-2 0.01123456 0.01123456 0.0112346
-1 0.1123456 0.1123456 0.112346
0 1.123456 1.123456 1.12346
1 11.23456 11.23456 11.2346
2 112.3456 112.3456 112.346
3 1123.456 1123.456 1123.46
4 11234.56 11234.56 11234.6
5 112345.6 112345.6 112346
6 1123456 1123456 1123456
7 11234560 1.123456e+07 11234560
8 112345600 1.123456e+08 112345600
9 1123456000 1.123456e+09 1123456000
10 11234560000 1.123456e+10 11234560000
11 112345600000 1.123456e+11 112345600000
12 1123456000000 1.123456e+12 1123456000000
13 11234560000000 1.123456e+13 11234560000000
14 1.123456e+14 1.123456e+14 112345600000000
15 1.123456e+15 1.123456e+15 1123456000000000
16 1.123456e+16 1.123456e+16 1.123456e+16
17 1.123456e+17 1.123456e+17 1.123456e+17
18 1.123456e+18 1.123456e+18 1.123456e+18
19 1.123456e+19 1.123456e+19 1.123456e+19
20 1.123456e+20 1.123456e+20 1.123456e+20
BrightScript Debugger> d = 1.1234567# : for i=-5 to 20: dd# = d*10#^i: ? i, dd#, str(dd#), fn(dd#): end for
-5 1.1234567e-05 1.123457e-05 1.12346e-05
-4 0.00011234567 0.0001123457 0.000112346
-3 0.0011234567 0.001123457 0.00112346
-2 0.011234567 0.01123457 0.0112346
-1 0.11234567 0.1123457 0.112346
0 1.1234567 1.123457 1.12346
1 11.234567 11.23457 11.2346
2 112.34567 112.3457 112.346
3 1123.4567 1123.457 1123.46
4 11234.567 11234.57 11234.6
5 112345.67 112345.7 112346
6 1123456.7 1123457 1.12346e+06
7 11234567 1.123457e+07 11234567
8 112345670 1.123457e+08 112345670
9 1123456700 1.123457e+09 1123456700
10 11234567000 1.123457e+10 11234567000
11 112345670000 1.123457e+11 112345670000
12 1123456700000 1.123457e+12 1123456700000
13 11234567000000 1.123457e+13 11234567000000
14 1.1234567e+14 1.123457e+14 112345670000000
15 1.1234567e+15 1.123457e+15 1123456700000000
16 1.1234567e+16 1.123457e+16 1.1234567e+16
17 1.1234567e+17 1.123457e+17 1.1234567e+17
18 1.1234567e+18 1.123457e+18 1.1234567e+18
19 1.1234567e+19 1.123457e+19 1.1234567e+19
20 1.1234567e+20 1.123457e+20 1.1234567e+20
BrightScript Debugger>
That being said, since the ultimate goal was for fake 64-bit integers, it works beautifully for that... better than both ? and Str(), but then, so did my original method...
BrightScript Debugger> ?fn(1234567890123456#)
1234567890123456
BrightScript Debugger> ?1234567890123456#
1.2345678901235e+15
BrightScript Debugger> ?Str(1234567890123456#)
1.234568e+15
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)