Programming If problem

Programming If problem - Messages

#1 Posted: 2/25/2020 4:32:39 PM
NONE

NONE

0 likes in 1 posts.

Group: User

Hi everyone,
I've got problem with 'if' statement.
Image: https://ibb.co/YcxjcqR
As you can see in the picture, y(3) is being counted by the second formula, but it must be counted by the third formula cos' x>2 and it must be equal 1. What's wrong with that? Thanks!
You can also download the original file by this link: https://ufile.io/qpnqpws9 (I could upload it on this forum, but it's stuck)

Note (English is not my native language, so I'm sorry if something incorrect)
#2 Posted: 2/25/2020 5:18:20 PM
Arie

Arie

93 likes in 285 posts.

Group: User

The formulation you have for the second if statement will always evaluate to true if reached.

If you look at your condition:
(0<=x)< 2
(0<=x) will evaluate to 1 if true or 0 if false. Both 1 and 0 are less than 2.
So will always evaluate to true because 1 < 2 is true and 0 < 2 is also true.

Attached is the proper way to perform that condition in SMATH
2.sm (7 KiB) downloaded 35 time(s).

Also the way that you have formulated the if statement f(2) will result in an error because none is not defined. If that's what you intend, that's fine. Otherwise you'd need equality <= or >= in the 2,3 if statement, respectively.
Feel free to join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW
#3 Posted: 2/25/2020 5:19:48 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

You can also download the original file


No point => that gadget is freak.

Freak.PNG
  • New Posts New Posts
  • No New Posts No New Posts