Closed bengolds closed 2 years ago
Hmmmm.... yes, that's intentional. Using d
as the exponent indicator is supported in Fortran and several calculators. I can see how that would be confusing if you expect d
to be a symbol instead. Although I guess that ambiguity exists for e
as well...
Not sure how to deal with this. I could just drop the d
marker. Or make it an option.
Ooh yeah, that's a tough one. A couple options, none of them great:
5d + 5
and 5d+5
(whitespace matters). d
marker altogether.Personally, to keep symmetry with e
, I'd pick option 2. 5e+5
and 5e + 5
read quite differently to me!
I think option 2 is already implemented (I haven't verified it, but I remember this was the intent at least). Dunno if it's enough, though...
Please do make it an option if possible. I personally have never seen the d
indicator and would be quite confused if it ended up parsing differently.
Looks like option 2 isn't implemented yet:
> c.parse('5d+5')
{ num: '5e5' }
> c.parse('5d + 5')
{ num: '5e5' }
Yea same issue. Using the D variable break everything. I think by default D should be a variable.
@DegrangeM - I think you're bumping into a different issue (which I also just ran into and made a ticket for): https://github.com/cortex-js/compute-engine/issues/32
Uppercase D
and lowercase d
seem to have quite different behavior 😄
0.4.3
appears to either 1 (optional, with dropped d
as default) or 3 (completely dropped).
In any case, I think this can probably be closed 😄
> p.parse('5d+5').json
[ 'Add', [ 'Multiply', 5, 'd' ], 5 ]
> p.parse('5d + 5').json
[ 'Add', [ 'Multiply', 5, 'd' ], 5 ]
I went with (3).
Perhaps this is some strange scientific notation I'm unfamiliar with, but the latex of
5d+5
parses as{ num: '5e5' }
instead of[ 'Add', [ 'Multiply', { num: '5' }, 'd' ], { num: '5' } ]
.To repro, call: