Skip to main content
Question

Issue in Deleting Last Digit: Unexpected 0.90 Instead of 1 in Number Reduction Function

  • February 24, 2025
  • 0 replies
  • 9 views

tara_singh1

I created a function that allows numbers to be added sequentially on a keypad in increments of *10. The logic works as follows:

  • Press 1 → Adds 1
  • Press 2 → Updates to 12 (appending 2 after 1)
  • Press 3 → Updates to 123

Similarly, I implemented another condition where pressing 1 three times should result in 111 instead of 12 or 123. I’ve attached a screenshot named 'add' to show this functionality.

Issue with Number Deletion

Now, I’m working on the minus function, which should remove digits in reverse order:

  • For 123, the deletion should happen like this: 123 → 12 → 1 → 0
  • For 111, it should go: 111 → 11 → 1 → 0

I’ve attached a screenshot named 'minus' for reference.

The Problem

When I test the function with 111, it works correctly—first becoming 11, then 1, and finally 0.

However, when I test it with 123, it correctly removes 3, then 2, but when it should change 1 to 0, it unexpectedly changes it to 0.90 instead.

What I Need Help With

Why is this happening? Why does the last digit of 123 turn into 0.90 instead of 0, while 111 works as expected?

Let me know if you need any additional details!

 

https://www.figma.com/design/UvomRummHza6e8nQEPwDCH/Swap-Currency---practice?node-id=41-8&t=3tkKRT5kSucSKtFn-1


 

0 replies

Be the first to reply!

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings