Rank: Newbie
Groups: Registered
Joined: 25/02/2020(UTC) Posts: 1 Location: None
|
Hi everyone, I've got problem with 'if' statement. Image: https://ibb.co/YcxjcqRAs 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) Edited by user 25 February 2020 23:34:03(UTC)
| Reason: Solved
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 23/03/2016(UTC) Posts: 278 Was thanked: 91 time(s) in 57 post(s)
|
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 (8kb) downloaded 18 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. Edited by user 25 February 2020 23:23:33(UTC)
| Reason: Not specified |
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 981 time(s) in 809 post(s)
|
Originally Posted by: NØ You can also download the original file No point => that gadget is freak.
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.