100 icon indicating copy to clipboard operation
100 copied to clipboard

Wrongly translated expressions in 005

Open ddiu8081 opened this issue 2 years ago • 0 comments

In 005: When translating expressions, when a number is divided by a number greater than 10, the result of the operation is not as expected.

Reproduction

(t, r, th) => sin(t / 10) got black results. I think it was translated to sin(t / 1 * 0).

My thoughts

  1. Wrong in regExp replacement method. /(\d+)(\w+)/g should be modified to /(\d+)([a-zA-Z]+)/g;
  2. I'm not sure if 1/3t should be translated as (1/3)*t or 1/(3*t), the current translation results in the former. If it should be the latter, the correct method should be exp.replace(/(\d+\.?\d?)([a-zA-Z]+)/g, (_, n, x) => `(${n} * ${x})`) (use brackets to enclose the result, and let number part matches float numbers)
  3. Another problem is that I can't type 3tr to represent 3*t*r, only get 3*tr and then got an error.

ddiu8081 avatar May 02 '22 13:05 ddiu8081