Programming If problem

Programming If problem - Сообщения

#1 Опубликовано: 25.02.2020 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 Опубликовано: 25.02.2020 17:18:20
Arie

Arie

93 сообщений из 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 КиБ) скачан 35 раз(а).

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 Опубликовано: 25.02.2020 17:19:48
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote

You can also download the original file


No point => that gadget is freak.

Freak.PNG
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений