Can you explain the different results

https://t.co/EAIR2kYD6K https://video.twimg.com/amplify_video/1775033822318350336/vid/avc1/576x1024/0dtCpCL452ODb6n6.mp4?tag=14

Reply to this note

Please Login to reply.

Discussion

Shitty code.

Yes.

Mobile: 50+50×2= 150

Traditional calculator: 50+50x2=200

Explanation:

Mobile's logic - It is using the logic MDAS where multiplication comes first than Division, Addition and Subtraction. In this case, it is multiplying the 50x2 = 100 + 50 = 150.

Tradtitional calculator: It is using left to right logic! Using brackets (){}[] is to explicitly say which one to calculate first. 50 + 50 = 100 × 2 = 200. Not all users are aware of MDAS. Therefore taking a raw input and arranging it to MDAS does not make sense. Some users simply want their numbers as it is or as it is inputted. The logic left to right, I believe is the correct approach. As a former programmer, I'd say this is a bad design. As a data specialist, I would not want my data input calculated in a way not known to me. The rules and the calculation must be transparent. 😀