tweak Str$ for single and double
#1
I think that this is worth looking into
Code: (Select All)
Dim As Single x
For x = 1 To .05 Step -.05
    Print x
Next x

output
Code: (Select All)
1
.95
.9
.85
.8
.7499999
.6999999
.6499999
.5999999
.5499999
.4999999
.4499999
.3999999
.3499998
.2999998
.2499998
.1999998
.1499998
9.999985E-02

if you change the format string in the function qbs *qbs_str(float value) in libqb.cpp from "% .6E" to "% .6G" you get

Code: (Select All)
1
0.95
0.9
0.85
0.8
0.75
0.7
0.65
0.6
0.55
0.5
0.45
0.4
0.35
0.3
0.25
0.2
0.15
0.0999998
similarly results for the function qbs *qbs_str(double value), changing the "E" to "G"

before change

Code: (Select All)
1
.95
.9
.85
.7999999999999998
.7499999999999998
.6999999999999997
.6499999999999997
.5999999999999996
.5499999999999996
.4999999999999996
.4499999999999996
.3999999999999996
.3499999999999996
.2999999999999997
.2499999999999997
.1999999999999997
.1499999999999997
.0999999999999997

after changing "E" to "G"
the change to G messes up if the exponent goes above 99 so more work is needed to make it work for the full range

Code: (Select All)
1
0.95
0.9
0.85
0.8
0.75
0.7
0.65
0.6
0.55
0.5
0.45
0.4
0.35
0.3
0.25
0.2
0.15
0.1
Reply


Messages In This Thread
tweak Str$ for single and double - by Jack - 12-01-2022, 02:09 AM
RE: tweak Str$ for single and double - by Pete - 12-01-2022, 04:20 AM
RE: tweak Str$ for single and double - by Jack - 12-01-2022, 12:17 PM
RE: tweak Str$ for single and double - by Pete - 12-01-2022, 02:09 PM
RE: tweak Str$ for single and double - by Jack - 12-01-2022, 02:19 PM
RE: tweak Str$ for single and double - by Pete - 12-01-2022, 02:24 PM
RE: tweak Str$ for single and double - by Pete - 12-01-2022, 03:51 PM



Users browsing this thread: 5 Guest(s)