expr-eval icon indicating copy to clipboard operation
expr-eval copied to clipboard

Feat: percent support

Open qfox opened this issue 8 years ago • 3 comments

Like 50 + 10%.

Strange cases: 50 + 10% - 5 — it can't be treated as 10 % -5, right?) 50 + 10% + 5 — if you going to get mod — you avoid using plus sign, right?.

As far as I see other operators after a percent sign could be treated as a syntax error.

p.s. Probably it could be nice to see some units support like 5cm, but it's another story.

qfox avatar May 29 '17 19:05 qfox

I'm considering this for a future release, but I'll need to work out the details of how it would work (including the parsing issues you brought up). I might end up replacing the current usage with a mod operator to avoid ambiguities and use % exclusively for percentages. I can definitely see how it would be nice for some use cases.

silentmatt avatar Jun 02 '17 18:06 silentmatt

I think it's fully compatible with % binary operator:

  • after binary % must be an expression
  • after unary % can be an operator or nothing

qfox avatar Jun 02 '17 19:06 qfox

+1

stoplion avatar Jul 31 '18 21:07 stoplion