Order of Operations: is the documentation correct?
#11
(02-14-2023, 07:21 PM)Kernelpanic Wrote: As already mentioned, the order in which the individual operators are considered is important.

Different operators at the same level are so executed: the leftmost operation first, the rightmost operation last.

If one want to be absolutely sure that a calculation is carried out in a certain order, then one just put brackets.

(a = 4.000 - a2 = 0.063 - a3 = 2.500)
Code: (Select All)
'Rangfolge von Operatoren - 14. Feb. 2023
'QuickBasic Befehlsverzeichnis 3.2

$Console:Only
Option _Explicit

Dim As Double a, a2, a3

a = 100 Mod 17 / 3
Print Using "###.###"; a

'There is one exception to the normal ranking:
'If an expression has adjacent exponentiation and negation operators,
'then the negation is performed first.
a2 = 4 ^ -2
Print Using "###.###"; a2

'The leftmost operation first, the rightmost operation last.
'According to their order of operations (Rangfolge)
a3 = 3 + 6 / 12 * 3 - 2
Print Using "###.###"; a3

End

The whole point of my OP was to indicate that the documentation does not match the behaviour.

All of the clarifications of behaviour in this thread are nice, but not of much use if the documentation isn't updated accordingly.

Who, learning QB64pe, is going to read about Order of Operations via a search of the forums versus reading the documentation in the wiki?  (Or maybe documentation is out of fashion and I need to get with the times.)

Meh.  I bow out of this discussion and leave it to the rest of the community to figure it out.
Reply
#12
(02-14-2023, 09:17 PM)CharlieJV Wrote: All of the clarifications of behaviour in this thread are nice, but not of much use if the documentation isn't updated accordingly.

Who, learning QB64pe, is going to read about Order of Operations via a search of the forums versus reading the documentation in the wiki?  (Or maybe documentation is out of fashion and I need to get with the times.)

Meh.  I bow out of this discussion and leave it to the rest of the community to figure it out.

Man, the age of the internet and instant gratification is rampant anymore.  The original post is all of 6 hours old, and you're already "bowing out of this discussion"?  RhoSigma is our main wiki maintainer and he's usually here much later in the evening/night due to the timezone in which he lives.  You've got to give folks time to see, verify, and respond to your posts, rather than just expecting to see the documentation change instantly.

The only way you'll ever see instant wiki updates is if you sign up and become an editor for the wiki yourself.  As much as you care about documentation, it seems like it'd be something right up your alley.  Let Rho know if you're interested and he'll pass you whatever login details you need to be able to make the changes yourself.
Reply
#13
(02-14-2023, 09:44 PM)SMcNeill Wrote:
(02-14-2023, 09:17 PM)CharlieJV Wrote: All of the clarifications of behaviour in this thread are nice, but not of much use if the documentation isn't updated accordingly.

Who, learning QB64pe, is going to read about Order of Operations via a search of the forums versus reading the documentation in the wiki?  (Or maybe documentation is out of fashion and I need to get with the times.)

Meh.  I bow out of this discussion and leave it to the rest of the community to figure it out.

Man, the age of the internet and instant gratification is rampant anymore.  The original post is all of 6 hours old, and you're already "bowing out of this discussion"?  RhoSigma is our main wiki maintainer and he's usually here much later in the evening/night due to the timezone in which he lives.  You've got to give folks time to see, verify, and respond to your posts, rather than just expecting to see the documentation change instantly.

The only way you'll ever see instant wiki updates is if you sign up and become an editor for the wiki yourself.  As much as you care about documentation, it seems like it'd be something right up your alley.  Let Rho know if you're interested and he'll pass you whatever login details you need to be able to make the changes yourself.

Nah, I had no expectations.

The resulting amount of effort put into replies when I thought it would just be a simple fix to the documentation surprised me and became quickly overwhelming.  For my own peace of mind, I had to bow out.  I don't expect anybody to understand it, and I don't have the energy to explain it.

As for the wiki, I tried once.  Bad experience.  Never again.  The process is too complicated for me, and my desire to make that documentation work for my needs is too strong.
Reply
#14
@CharlieJV

The page you mention in your inital post wasn't updated for years, so whatever behavior is described on it can be seen as long standing fact. I.e. if the docs (currently) doesn't match up with the behavior, then I would first consider that a bug was introduced with recent changes, rather than taking the behavior "to be law" and immediatly change a long standing documentation to match that law.

I've never worked on the parts of QB64 responsible for math evaluation, so it may take a while for me and the other devs to figure out what happened, and I can assure that I'll change/correct the documentation if required, but I'll certainly not do a "Quick Shot" now, just for the sake of one member's satisfaction and then starting again in a short time to revert the changes when it turns out it's really just a stupid bug in math evaluation.
Reply
#15
(02-15-2023, 12:39 AM)RhoSigma Wrote: @CharlieJV

 but I'll certainly not do a "Quick Shot" now, just for the sake of one member's satisfaction 

Trying to point out problems in documentation or inconsistencies between documentation and QB64/QB64pe was about the best I could manage in regards to contributions to the project and community.

For this to be taken as something that needs to be done asap and to my satisfaction, that's a clear sign that I can't even offer this little type of contribution.

Too much of a headache.  Never mind.  I won't be doing this again.
Reply
#16
Hi @RhoSigma

Don't think there is any bug. It just lacks detail of complete breakdown of the order in which the operations are handled.
The wiki is implying division is on the same level as MOD yet all division is done before all MODs are considered in an expression, just as Steve has gone over in this thread.

I was surprised myself because I consider MOD a function because of the 3 letters no symbols. But a function would require ()'s I see now, so it is a binary operation like addition.
b = b + ...
Reply




Users browsing this thread: 4 Guest(s)