how do I phrase an "if("float" is > 90 but < than 180)"

   842   6   2
User Avatar
Member
34 posts
Joined: 12月 2020
Offline
so I have worked out how to do my trigonometry in vex. But I am confusing myself with the "if" question.
I need to get a value within a range? my heads broken.
User Avatar
Member
34 posts
Joined: 12月 2020
Offline
sussed it out
if((name > 90) && (name <180))
{
do this;
}

Please correct me if I have this wrong
User Avatar
Member
4516 posts
Joined: 2月 2012
Offline
That looks correct but you don't need extra parentheses;

if ( name > 90 && name < 180 )
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
User Avatar
Member
900 posts
Joined: 2月 2016
Offline
I've always hoped to be able to do
if(90< name < 180)

it'd make it faster to type and to grasp on quick look
User Avatar
スタッフ
5160 posts
Joined: 7月 2005
Offline
Andr
I've always hoped to be able to do
if(90< name < 180)

it'd make it faster to type and to grasp on quick look

That's a scary expression, because it would look like it's working, but it'd evaluate (90<name) first, giving you 0 or 1, which is then always less than 180, so the expression is always true. If it worked in VEX, it would bite you when you started programming in some other language.
User Avatar
Member
900 posts
Joined: 2月 2016
Offline
ah, thanks!
User Avatar
Member
34 posts
Joined: 12月 2020
Offline
That looks correct but you don't need extra parentheses;

if ( name > 90 && name < 180 )

@animatrix_

Thanks for the tip ;-)
  • Quick Links