Graal Forums  

Go Back   Graal Forums > Development Forums > Tech Support
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-10-2006, 07:17 AM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
Operator Precedence

I'm makeing a jump function, and this precedence of operators is really screwing me up.
2*(dy-v*t)/t^2 != 2*(dy-v*t)/(t^2)

Shouldn'y the ^ operator have a higher precedence than all of the other operators?
Reply With Quote
  #2  
Old 01-10-2006, 07:51 AM
Rick Rick is offline
PipBoy Extraordinaire!
Rick's Avatar
Join Date: Jul 2004
Location: Long Beach, California.
Posts: 831
Rick is on a distinguished road
No, even in C it isn't.
Reply With Quote
  #3  
Old 01-10-2006, 08:10 AM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
Quote:
Originally Posted by Rick
No, even in C it isn't.
Uhhh... isn't it the xor operator in C? In math operations it should hold higher precedence than /* and lower than ()
Reply With Quote
  #4  
Old 01-10-2006, 08:37 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
What's so bad about adding the () anyway?
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #5  
Old 01-10-2006, 09:45 AM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
Quote:
Originally Posted by napo_p2p
What's so bad about adding the () anyway?
It's not so bad about adding parenthesis, but it's disgusting that it contradicts the universal standard mathematical order of operations.
Reply With Quote
  #6  
Old 01-10-2006, 09:57 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by jake13jake
It's not so bad about adding parenthesis, but it's disgusting that it contradicts the universal standard mathematical order of operations.
I see where you are coming from but...

Quote:
Originally Posted by jake13jake
I'm makeing a jump function, and this precedence of operators is really screwing me up.
That made it seem like this "operator precedence problem" was keeping you from making your script.
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #7  
Old 01-10-2006, 10:31 AM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
Quote:
Originally Posted by napo_p2p
I see where you are coming from but...



That made it seem like this "operator precedence problem" was keeping you from making your script.
Seriously, I spent too much time the last three days rewriting the position equation in my notebook and solving for acceleration, trying to figure out what was wrong with it when the problem preventing me from moving forward was this operator precedence problem.
Reply With Quote
  #8  
Old 01-10-2006, 04:35 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
I recommend adding brackets whenever you are unsure about the results, since there are a lot of operators in Graal. But it is true that the order of operations is not correct, it is treating multiplication and division with the same priority as exponents, while exponents should be calculated first, like in v2.
I have fixed it, the npcservers need to be restarted.
Reply With Quote
  #9  
Old 01-11-2006, 01:31 AM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
Quote:
Originally Posted by Stefan
I recommend adding brackets whenever you are unsure about the results, since there are a lot of operators in Graal. But it is true that the order of operations is not correct, it is treating multiplication and division with the same priority as exponents, while exponents should be calculated first, like in v2.
I have fixed it, the npcservers need to be restarted.
I never have had a problem with the math order of operations, but sometimes with the conditionals... which i would use parenthesis anyways.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 05:09 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.