Simple arithmetic

  • DonlSimpson

    SSCertifiable

    Points: 6774

    Comments posted to this topic are about the item Simple arithmetic

    Don Simpson



    I'm not sure about Heisenberg.

  • Koen Verbeeck

    SSC Guru

    Points: 258955

    Nice question, thanks.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • This was removed by the editor as SPAM

  • Emil B

    SSCertifiable

    Points: 5568

    i saw lots of people on social sites having problems with:

    1+1+1+1+1+1+1+1+1+1+1+1x0+1 = ?

    most of the answers was 1. So saying Simple may apply differently to others :hehe:

  • Gazareth

    One Orange Chip

    Points: 27737

    It's. Too. Early. For. This. 🙂

  • Ed Wagner

    SSC Guru

    Points: 286960

    It was simple math, but also a simple exercise in clear thinking, something I would think that most people who work in databases would be good at. Thanks.

  • paul.knibbs

    SSCoach

    Points: 15270

    Emil Bialobrzeski (12/10/2014)


    i saw lots of people on social sites having problems with:

    1+1+1+1+1+1+1+1+1+1+1+1x0+1 = ?

    most of the answers was 1. So saying Simple may apply differently to others :hehe:

    Slightly unfair question, though, because the answer depends on operator precedence. For instance, I was never taught at school that multiplication takes priority over addition, and if you just process that statement left to right, then the answer *is* 1--you add a load of 1s together, multiply that by zero, and add 1 to the result.

  • Hany Helmy

    SSChampion

    Points: 13435

    paul.knibbs (12/10/2014)


    Emil Bialobrzeski (12/10/2014)


    i saw lots of people on social sites having problems with:

    1+1+1+1+1+1+1+1+1+1+1+1x0+1 = ?

    most of the answers was 1. So saying Simple may apply differently to others :hehe:

    Slightly unfair question, though, because the answer depends on operator precedence. For instance, I was never taught at school that multiplication takes priority over addition, and if you just process that statement left to right, then the answer *is* 1--you add a load of 1s together, multiply that by zero, and add 1 to the result.

    ++1

  • Xavon

    SSCrazy

    Points: 2280

    paul.knibbs (12/10/2014)


    Emil Bialobrzeski (12/10/2014)


    i saw lots of people on social sites having problems with:

    1+1+1+1+1+1+1+1+1+1+1+1x0+1 = ?

    most of the answers was 1. So saying Simple may apply differently to others :hehe:

    Slightly unfair question, though, because the answer depends on operator precedence. For instance, I was never taught at school that multiplication takes priority over addition, and if you just process that statement left to right, then the answer *is* 1--you add a load of 1s together, multiply that by zero, and add 1 to the result.

    Wow, really? Proper order of operations is fairly important in most high level maths. I remember having drills wherein we had to take math expressions and add parentheses to show how the statement should be parsed.

  • davoscollective

    SSCertifiable

    Points: 6325

    Xavon (12/10/2014)


    paul.knibbs (12/10/2014)


    Emil Bialobrzeski (12/10/2014)


    i saw lots of people on social sites having problems with:

    1+1+1+1+1+1+1+1+1+1+1+1x0+1 = ?

    most of the answers was 1. So saying Simple may apply differently to others :hehe:

    Slightly unfair question, though, because the answer depends on operator precedence. For instance, I was never taught at school that multiplication takes priority over addition, and if you just process that statement left to right, then the answer *is* 1--you add a load of 1s together, multiply that by zero, and add 1 to the result.

    Wow, really? Proper order of operations is fairly important in most high level maths. I remember having drills wherein we had to take math expressions and add parentheses to show how the statement should be parsed.

    Order of operations is an arbitrary syntax decision, and not necessarily implemented consistently in programming languages. Yes there is a standard in mathematics but it could easily have been different. It could have been that there was no decision at all and that the only way to guarantee order was with parentheses. Luckily parentheses are given priority, at least in every language I've come across. Doesn't hurt to add them in anyway, otherwise questions like that are just syntax memory tests rather than logic tests.

    back to the real topic. I enjoyed the question. I suppose that depending on the underlying implementation, it could save a little memory 🙂

  • akljfhnlaflkj

    SSC Guru

    Points: 76202

    Nice math swap. Now is there something like that for strings?

  • domenico.delbrocco

    Mr or Mrs. 500

    Points: 587

    Nice but simple question: I'm wondering why it worths 2 points

  • doug.davidson

    SSCommitted

    Points: 1552

    Hany Helmy (12/10/2014)


    paul.knibbs (12/10/2014)


    Emil Bialobrzeski (12/10/2014)


    i saw lots of people on social sites having problems with:

    1+1+1+1+1+1+1+1+1+1+1+1x0+1 = ?

    most of the answers was 1. So saying Simple may apply differently to others :hehe:

    Slightly unfair question, though, because the answer depends on operator precedence. For instance, I was never taught at school that multiplication takes priority over addition, and if you just process that statement left to right, then the answer *is* 1--you add a load of 1s together, multiply that by zero, and add 1 to the result.

    ++1

    I think you need a refund on your base math education. BEDMAS was drilled into us here in the Great White North starting at age 10 (Grade 5), and continued through to end of Math in high school.

    Since BEDMAS might be unknown

    B - Brackets

    E - Exponents

    DM - Division / Multiplication

    AS - Addition / Subtraction

  • TomThomson

    SSC Guru

    Points: 104772

    Xavon (12/10/2014)


    paul.knibbs (12/10/2014)


    Emil Bialobrzeski (12/10/2014)


    i saw lots of people on social sites having problems with:

    1+1+1+1+1+1+1+1+1+1+1+1x0+1 = ?

    most of the answers was 1. So saying Simple may apply differently to others :hehe:

    Slightly unfair question, though, because the answer depends on operator precedence. For instance, I was never taught at school that multiplication takes priority over addition, and if you just process that statement left to right, then the answer *is* 1--you add a load of 1s together, multiply that by zero, and add 1 to the result.

    Wow, really? Proper order of operations is fairly important in most high level maths. I remember having drills wherein we had to take math expressions and add parentheses to show how the statement should be parsed.

    Yes, operator precedence is very important. That's why both computer languages and mathematical calculi and notations define operator precedence rigorously. There are pleny of languages/calculi where precedence is defined to be purely left to right except unless there are special cases like for example the use of brackets or some other precedence modifying syntax (eg in mathematics the lambda calculus and some of its derivatives, and in computing several programming languages based on them) and also notations where precedence is purely left to right or purely right to left - think of Polish notation and reverse Polish notation, which are respectively left to right and right to left: both are commonly used in both maths and computing. Given the expression 1+1x0+1 the value could be 3,1, or 2 depending on the precedence rules so unless either the language/notation is specified or the precedence rules are defined without mentioning the language/notation there's no knowing what the value is. Sure, in a junior high school maths test the answer will probably be 2 because no-one has yet been taught that there's more than one possible notation, but that doesn't mean that that's always the right answer.

    Tom

  • Sean Lange

    SSC Guru

    Points: 286483

    davoscollective (12/10/2014)


    Xavon (12/10/2014)


    paul.knibbs (12/10/2014)


    Emil Bialobrzeski (12/10/2014)


    i saw lots of people on social sites having problems with:

    1+1+1+1+1+1+1+1+1+1+1+1x0+1 = ?

    most of the answers was 1. So saying Simple may apply differently to others :hehe:

    Slightly unfair question, though, because the answer depends on operator precedence. For instance, I was never taught at school that multiplication takes priority over addition, and if you just process that statement left to right, then the answer *is* 1--you add a load of 1s together, multiply that by zero, and add 1 to the result.

    Wow, really? Proper order of operations is fairly important in most high level maths. I remember having drills wherein we had to take math expressions and add parentheses to show how the statement should be parsed.

    Order of operations is an arbitrary syntax decision, and not necessarily implemented consistently in programming languages. Yes there is a standard in mathematics but it could easily have been different. It could have been that there was no decision at all and that the only way to guarantee order was with parentheses. Luckily parentheses are given priority, at least in every language I've come across. Doesn't hurt to add them in anyway, otherwise questions like that are just syntax memory tests rather than logic tests.

    back to the real topic. I enjoyed the question. I suppose that depending on the underlying implementation, it could save a little memory 🙂

    Can you show me an example of any programming language that does not support the mathematical agreed upon order of operations?

    The question above is NOT a syntax memory test, it tests your understanding of the order of operations for math.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

Viewing 15 posts - 1 through 15 (of 31 total)

You must be logged in to reply to this topic. Login to reply