Image Map Image Map
Page 5 of 11 FirstFirst 123456789 ... LastLast
Results 41 to 50 of 104

Thread: Slow News Day

  1. #41

    Default

    Quote Originally Posted by SomeGuy View Post
    When I come across something like this, the first thing that comes to my mind is "What were you trying to actually DO?" The context of WHY these numbers are being added or multiplied would shed light on if the implementation is correct or not.

    Another piece of code where nobody kept the business requirements! [Runs for the hills]
    This is the correct answer. People keep saying that is math, but it isn't really. There is nothing about PPMDAS that is required for "truth." As it says on wikipedia, "These conventions exist to eliminate ambiguity while allowing notation to be as brief as possible." I think the best solution, espcially these days is to not worry too much about being brief, and reduce ambiguity as much as possible. I would not want to write an equation where, depending on how the order of operations was implemented, I'd get different answers.

  2. #42

    Default

    Quote Originally Posted by vwestlife View Post
    No one remembers Please Excuse My Dear Aunt Sally?
    I always heard it growing up as Pretty Please, My Dear Aunt Sally. Were the second P was "powers" but this one is less ambiguous. I've also heard people say PEDMAS, which seems to swap the Division and Multiplication.

  3. #43

    Default

    Just to add to the noise. 16.
    There is no implied parentheses, grouping the (2+2) with the denominator.
    It is the reason RPN works better for solving problems. Parentheses can be used for something else.
    Algebraic notation works better for manipulating equations, not solving problems.
    In lining operations on a single line came about when people tried to put algebraic equations in a text for for computers to figure out how to solve for answers.
    RPN has no such ambiguity. Operations are executed left to right, just as you read them.
    Dwight

  4. #44
    Join Date
    Jan 2007
    Location
    Pacific Northwest, USA
    Posts
    31,972
    Blog Entries
    18

    Default

    @lowen, you're speaking about computer math. But that's not everyday arithmetic. I've been up to my elbows in complier front-ends and can confirm your argument is valid, for most languages--but not APL (which is why the assignment operator is on the left of the expression to be computed, not the right). So there are the outliers.

    As I noted, there are some interesting exceptions in published works.

    My "The Radio Handbook" for 1942 says this under "Order of Operations", page 534:

    ...First, all powers and roots should be calculated; multiplication and division come next; adding and subtraction come last...if a series of operations should be performed in a different order, this is always indicated by parentheses and brackets
    My take on the Feynmann and the Landau and Lifshitz references are outliers in general practice and not generally accepted.

    As far as the criticism of GWBASIC and Messrs. Gates and Allen goes, show me a FORTRAN or BASIC that arrives at a different answer. As far as division being the same as multiplication by a reciprocal, not really in practice--computer math is finite precision and you'll often get a different answer by the so-called "reduction in strength".
    Last edited by Chuck(G); August 2nd, 2019 at 08:11 AM.

  5. #45
    Join Date
    Sep 2008
    Location
    SE MI
    Posts
    4,072
    Blog Entries
    6

    Default

    I know there are some sailors and marines out there, present or former, who had hours and hours of math in the Navy's Class "B" electronics schools - let's hear from you. We were taught left to right. I say "16". These are the same schools that for whatever reason dwelled on AC math, which championed imaginary numbers and vectors in the form of "j" factors, and 2 forms of magnetism; English and metric. When I was in these schools, math was accomplished via the Pickett 1010 slide rule and there were standards for straight lining equations. The only instances that I recall where one varied in the order of the process was when the problem included a "=" sign.
    Surely not everyone was Kung-fu fighting

  6. #46

    Default

    My recollection from 1970's grammer/HS and 1980's college

    As written:

    8 / 2 * (2 + 2)
    1: Parens first: 2 + 2 = 4
    2: Div & Mult have equal precedence, so left to right: 8 / 2 * 2 = 4 * 4 = 16

    I believe C, JS, Python and probably Perl is the same way (additional orders of precedence of course). And yes, I have gotten quite used to RPN where I would have rewritten it. But I'd also do the same with the other languages to make sure I don't mess up the equation and I know the order of precedence will be what I want.
    I didn't learn the PEDMAS (P Dumb *SS ). I'll remember that for now. Doesn't exactly help with C or asm language though.

  7. #47
    Join Date
    Sep 2003
    Location
    Ohio/USA
    Posts
    7,593
    Blog Entries
    2

    Default

    I find it funny how people are arguing how a computer does the calculations compared to how they should be done from a pure mathematical point.

    Is it really 8/2(2+2) or 8/2 x (2+2) or really 8/(2 X (2+2)).

    I seen it as it was written to have the answer of 1 because there was no x between the first 2 and the (. So the 2(2+2) is done first and divided into 8.
    What I collect: 68K/Early PPC Mac, DOS/Win 3.1 era machines, Amiga/ST, C64/128
    Nubus/ISA/VLB/MCA/EISA cards of all types
    Boxed apps and games for the above systems
    Analog video capture cards/software and complete systems

  8. #48

    Default

    The fact that this was on Fox news had nothing to do with anything. So next time, I wouldn't even put that in the subject of the thread. (And I've fixed it.)

    The debate is an excellent example of why ambiguity is bad, and can be expensive. (This is the kind of thing that causes rockets to blow up - poor/incomplete/ambiguous specifications.)

  9. #49
    Join Date
    Jan 2010
    Location
    Central VA
    Posts
    4,575

    Default

    Quote Originally Posted by mbbrutman View Post
    The debate is an excellent example of why ambiguity is bad, and can be expensive. (This is the kind of thing that causes rockets to blow up - poor/incomplete/ambiguous specifications.)
    And why even a one-line IF statement in C should have the curly braces

  10. #50
    Join Date
    Sep 2008
    Location
    SE MI
    Posts
    4,072
    Blog Entries
    6

    Default

    Quote Originally Posted by mbbrutman View Post
    The fact that this was on Fox news had nothing to do with anything. So next time, I wouldn't even put that in the subject of the thread. (And I've fixed it.)
    Mike,

    I strongly disagree with you logic in "censoring" the post. Readers should have the right to know where the source originated. I see no harm perceived or real in that. As far as I know, Fox was the only one carrying the story and it was intended as a source of amusement at the time it aired, and now you've made it appear political or at least factional. It's your bat and ball so I'll try to be more intune with your literary policies in the future.

    Tom
    Surely not everyone was Kung-fu fighting

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •