Those pits encountered in iOS development

Click to follow  asynchronous books , stick to the public number

Share with you every day the knowledge of IT good book technology dry goods workplace​


The previous project of a company was an e-commerce platform app called e-point office. Let's talk about the pits encountered in the development.

The app has such a function that users can choose to pay in installments when using the app to purchase goods. The specific installments, how much to pay in each installment, and when to pay are all set by the user himself, isn't it very user-friendly? After the application is staged, it will show that it is under review. Among them, the sum of each repayment amount to be calculated must be equal to the commodity amount, otherwise an error will be prompted.

I don’t know if everyone understands this function. As required, I add up the repayment amount of each period. If it is not equal to the amount of the product, it will prompt an error, and if it is equal, it will show that it is under review.

After the function was completed, the testers encountered problems during the test. The commodity price was assumed to be 0.3 yuan, and it was paid back in two installments. The first installment was 0.1 yuan, and the second installment was 0.2 yuan. When submitting, it prompts an error, it is impossible, I will check my code, and there is nothing wrong with the logic. Is 0.1+0.2 not equal to 0.3.

This problem bothered me all afternoon, and the test gloated on the side, let me solve this bug quickly. I printed the result and found that it is indeed not equal. I changed it like this, if the error is less than 0.000001, they are considered equal. Now that I think about it, I was too smart at the time.

Through this experience, I know that you should be extra careful when you encounter floating-point operations in development, and don't be troubled by some small problems. Did you encounter the same problem during development?

This article comes from the asynchronous community, author: brother name "Those pits encountered in iOS development"

Recommended reading

April 2018 new book list

The most complete Python book list of asynchronous books

A must-have algorithm book list for programmers

The first Python neural network programming book

​Long press the QR code to follow us

Share IT good articles with you every day.


Reply "Follow" in the background of "Asynchronous Books", you can get 2000 online video courses for free; recommend friends to follow the prompts to get the book gift link, and get a free asynchronous e-reading book. Come join now!

read the original


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326119757&siteId=291194637