/ Check-in [8ec811c95d]
DEMO | DOWNLOAD | DEPLOY | SEARCH
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Reduce precision for dbl.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:8ec811c95d17cced543c33dc1bf1bd0e4dee5692
User & Date: pmacdona 2019-05-06 14:07:52
Context
2019-05-07
16:09
Release "2.8.25". Fix function toString. check-in: c4e699bfd5 user: pmacdona tags: trunk
2019-05-06
14:07
Reduce precision for dbl. check-in: 8ec811c95d user: pmacdona tags: trunk
13:45
Allow changing subOpts:dblPrec check-in: 2f209a4541 user: pmacdona tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/jsiNumber.c.

57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{
    Jsi_Number r = INFINITY;
    return (Jsi_NumberIsNaN(value)==0 && value != r && r != -value);
}

void Jsi_NumberDtoA(Jsi_Interp *interp, Jsi_Number value, char* buf, int bsiz, int prec)
{
    int dp = interp->subOpts.dblPrec, dm = __DBL_DECIMAL_DIG__;
    if (prec==0)
        prec = (dp<=0?dm+dp:dp);
    else if (prec<0)
            prec = dm+prec;
    if (prec<=0)
        prec = dm-1;
    if (Jsi_NumberIsNaN(value))







|







57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{
    Jsi_Number r = INFINITY;
    return (Jsi_NumberIsNaN(value)==0 && value != r && r != -value);
}

void Jsi_NumberDtoA(Jsi_Interp *interp, Jsi_Number value, char* buf, int bsiz, int prec)
{
    int dp = interp->subOpts.dblPrec-1, dm = __DBL_DECIMAL_DIG__;
    if (prec==0)
        prec = (dp<=0?dm+dp:dp);
    else if (prec<0)
            prec = dm+prec;
    if (prec<=0)
        prec = dm-1;
    if (Jsi_NumberIsNaN(value))

Changes to tests/math.jsi.

46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
Number.toPrecision(9.1234,2) ==> 9.1
Number.toExponential(9.1234,2) ==> 9.12e+00
Number.toFixed(9.1234,2) ==> 9.12
j = new Number(9.1234) ==> 9.1234
j.toPrecision(2) ==> 9.1
j.toExponential(2) ==> 9.12e+00
j.toFixed(2) ==> 9.12
Math.tan(9) ==> -0.4523156594418098
Number.toPrecision(k,2) ==> -0.4
Number.toPrecision(Math.tan(9),2) ==> -0.4
Number.toExponential(k,2) ==> -4.52e-01
Number.toFixed(k,2) ==> -0.45
Math.abs(-1) ==> 1
Math.acos(1) ==> 0
Math.asin(1) ==> 1.570796326794897
Math.atan(1) ==> 0.7853981633974483
Math.atan2(0.4,5) ==> 0.07982998571223732
Math.cos(1) ==> 0.5403023058681398
Math.sin(1) ==> 0.8414709848078965
Math.exp(2) ==> 7.38905609893065
Math.ceil(5.33) ==> 6
Math.floor(5.33) ==> 5
Math.log(5.33) ==> 1.673351238177753
Math.max(1,2,3) ==> 3
Math.min(1,2,3) ==> 1
Math.pow(2,3) ==> 8
Math.round(5.33) ==> 5
Math.sqrt(5.33) ==> 2.308679276123039
1/0 ==> +Infinity
-1/0 ==> -Infinity
x = Math.pow(2,6) ==> 64
x.toString(16) ==> 40
x.toString(10) ==> 64
x.toString(8) ==> 100
x.toString(2) ==> 64
=!EXPECTEND!=
*/







|






|
|
|
|
|



|




|









46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
Number.toPrecision(9.1234,2) ==> 9.1
Number.toExponential(9.1234,2) ==> 9.12e+00
Number.toFixed(9.1234,2) ==> 9.12
j = new Number(9.1234) ==> 9.1234
j.toPrecision(2) ==> 9.1
j.toExponential(2) ==> 9.12e+00
j.toFixed(2) ==> 9.12
Math.tan(9) ==> -0.45231565944181
Number.toPrecision(k,2) ==> -0.4
Number.toPrecision(Math.tan(9),2) ==> -0.4
Number.toExponential(k,2) ==> -4.52e-01
Number.toFixed(k,2) ==> -0.45
Math.abs(-1) ==> 1
Math.acos(1) ==> 0
Math.asin(1) ==> 1.5707963267949
Math.atan(1) ==> 0.785398163397448
Math.atan2(0.4,5) ==> 0.0798299857122373
Math.cos(1) ==> 0.54030230586814
Math.sin(1) ==> 0.841470984807897
Math.exp(2) ==> 7.38905609893065
Math.ceil(5.33) ==> 6
Math.floor(5.33) ==> 5
Math.log(5.33) ==> 1.67335123817775
Math.max(1,2,3) ==> 3
Math.min(1,2,3) ==> 1
Math.pow(2,3) ==> 8
Math.round(5.33) ==> 5
Math.sqrt(5.33) ==> 2.30867927612304
1/0 ==> +Infinity
-1/0 ==> -Infinity
x = Math.pow(2,6) ==> 64
x.toString(16) ==> 40
x.toString(10) ==> 64
x.toString(8) ==> 100
x.toString(2) ==> 64
=!EXPECTEND!=
*/