Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix arithmetic issue between real and integer #7

Open
mohan10216 opened this issue Feb 20, 2022 · 0 comments
Open

Fix arithmetic issue between real and integer #7

mohan10216 opened this issue Feb 20, 2022 · 0 comments

Comments

@mohan10216
Copy link

mohan10216 commented Feb 20, 2022

Describe the bug
The first issue is that when I am programming I need to multiply two numbers which may either be Real or Integer. But it only gives me the correct result when I put the real number first then the integer.

The second issue is that when doing arithmetic we cannot use brackets.

Code required to reproduce

Error 1:

Take the following example

DECLARE x: INTEGER
DECLARE y: REAL
DECLARE z: REAL

x <- 5
y <- 5.2
z <- x * y

OUTPUT z

This should give the value of 26 since 5 * 5.2 = 26. However it gives an output of -0.2 which is clearly incorrect. However if we invert the variables so that we have z <- y * x we get 26. This means that multiplication only works if you multiply by a real number first followed by an integer. Multiplication should be universal to allow for interchangeability.

Error 2:

Take the following example

DECLARE x: INTEGER
DECLARE y: REAL
DECLARE z: REAL

x <- 5
y <- 5.2
z <- y * x + y

OUTPUT z

This code is correct as it fixes the error from above and gives an output of 31.2. However, adding brackets, z <- (y * x) + y, which should still give 31.2, but gives RuntimeError: Invalid primary type. (INTERNAL ERROR) instead.

Expected behavior
This should not be the case for either as multiplication should be commutative and brackets should be allowed when doing arithmetic.

Desktop (please complete the following information):

  • OS: MAC
  • Architecture: 64 Bit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant