Programming If problem

Programming If problem - 消息

#1 已发布: 2020/2/25 16:32:39
NONE

NONE

0个赞,共1个帖子。

组: 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 已发布: 2020/2/25 17:18:20
Arie

Arie

94个赞,共285个帖子。

组: 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.12 KiB)已下载 1153 次。

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 已发布: 2020/2/25 17:19:48
Jean Giraud

Jean Giraud

983个赞,共6,866个帖子。

组: User

Wrote

You can also download the original file


No point => that gadget is freak.

Freak.PNG
  • 有新帖
  • 无新帖