Entering malformed expressions leads to accepted input

Bug #1295944 reported by Victor Thompson
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Ubuntu Calculator App
Fix Released
Low
Bartosz Kosiorek

Bug Description

Entering calculations such as "1+=", "1/=", 1*=", and 1-=" all evaluate to automatically add the same number after the operator such that the expression is "1+1=".

To reproduce:
1. Enter the following expression: "1+="
2. Note that the output is "2" as a result of adding 1 and 1

Expected results: The expression is not completed because it is malformed. Perhaps the previous operand, 1, was accidentally used again.

Tags: bitesize

Related branches

Changed in ubuntu-calculator-app:
status: New → Confirmed
assignee: nobody → Bartosz Kosiorek (gang65)
Revision history for this message
Mihir Soni (mihirsoni) wrote :

Hi ,

Thanks for the bug, but it is expected behaviour of the calculator.

If you see any calculator and perform this expression it'll do with the previous operand.

Changed in ubuntu-calculator-app:
status: Confirmed → Incomplete
Revision history for this message
Victor Thompson (vthompson) wrote :

I disagree that this should be expected behavior. Can you name one calculator application that expands "1+=" to 2? It should either be invalid or just 1.

Revision history for this message
Sam Bull (dreamsorcerer) wrote :

I thought it was agreed awhile back in another bug report, that equals should be treated like an operand, and so replaces the trailing operand. I thought it was changed to that behaviour at the time, perhaps it's been changed again. Discussion: https://bugs.launchpad.net/ubuntu-calculator-app/+bug/1226738/comments/4

Revision history for this message
Bartosz Kosiorek (gang65) wrote :

In my opinion expected behavior is when you type "1+1="
It display "2".
After press "=" it will add additional "1".
So it will be "1+1=2=+1=3

In my opinion this issue is a bug and calculator should display "Syntax error"

Changed in ubuntu-calculator-app:
status: Incomplete → Confirmed
Revision history for this message
Bartosz Kosiorek (gang65) wrote :

By the way "gnome-calculator" after typing "1+" and press "=" display syntax error.

Revision history for this message
Victor Thompson (vthompson) wrote :

The discussion Sam mentions in comment #3 was resolved by changing "9 x 9 -" from being evaluated as "9 x 9 - 9" to "9 x9"--dropping the last operator. I think the same could apply here (meaning "1 +" would result in "1"). This is how the android calculator handles this evaluation. But I also agree that syntax error would be acceptable, but we'd want to change the implementation to also give a syntax error in the case mentioned in comment #3. Path of least resistance might be to simply drop the last operator.

Revision history for this message
Bartosz Kosiorek (gang65) wrote :

The problem existing only for one digit numbers:
Example:
   1+= gives 1+1=2

But:
  11+= gives 11=11

I will take a look at this issue and send solution proposal soon.

Thanks!

Changed in ubuntu-calculator-app:
status: Confirmed → In Progress
Revision history for this message
Mihir Soni (mihirsoni) wrote :

I understood , we haven't implemented this but after getting bug https://bugs.launchpad.net/ubuntu-calculator-app/+bug/1203435

We have implemented this , if we would like to revert we can revert it back.

Revision history for this message
Bartosz Kosiorek (gang65) wrote :

I'm a little bit confused.
To correct numbers/operators "backspace" key could be used. In future I would like to think how to add such virtual key to calculator.

I'm wondering why "=" operator correct only one digit numbers.
I prepared fix for this bug report in a branch. Please take a look and add some comment.

Thanks

David Planella (dpm)
Changed in ubuntu-calculator-app:
importance: Undecided → Low
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :

Fix committed into lp:ubuntu-calculator-app at revision 242, scheduled for release in ubuntu-calculator-app, milestone 1.6

Changed in ubuntu-calculator-app:
status: In Progress → Fix Committed
Changed in ubuntu-calculator-app:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.