Basic concepts of Android floating point

Source: Internet
Author: User

The Android mobile phone operating system has been well received by many users, especially programmers. Because of its open-source nature, it can well meet various user needs. Here we will analyze some concepts related to Android floating point to help you better understand this operating system.

  • Android lifecycle concepts
  • Overview of Android Defects
  • Android glossary Overview
  • Introduction to the correct implementation of Android read/write files
  • Android full screen

Avoid using Android floating point numbers

Before the emergence of the Pentium CPU, the game designers did the most integer operations. With the arrival of the Pentium, the floating point computing processor has become a built-in feature of the CPU. The use of floating point and integer can make your game run more smoothly. Generally on a desktop computer, you can use floating point operations at will.

Unfortunately, the embedded processor usually does not support Android floating point operations. All the operations on "float" and "double" are implemented through software. Some basic floating point operations can be completed in milliseconds.

It is even an integer. Some chips have hardware support for multiplication but lack Division support. In this case, the division and modulo operations of integers are also completed by software. Therefore, be cautious when using hash tables or performing a large number of mathematical operations.

Performance data

To illustrate our point of view, we listed a table to indicate the time required for some basic operations. These time values are not absolute values, but a mixture of CPU time and clock time. As the system improves, the running time will be shortened. However, we need to pay attention to the ratio between these values. For example, adding a member variable will take four times more time than adding a local variable.

 
  1. Action Time   
  2. Add a local variable 1   
  3. Add a member variable 4   
  4. Call String.length() 5   
  5. Call empty static native method 5   
  6. Call empty static method 12   
  7. Call empty virtual method 12.5   
  8. Call empty interface method 15   
  9. Call Iterator:next() on a HashMap 165   
  10. Call put() on a HashMap 600   
  11. Inflate 1 View from XML 22,000   
  12. Inflate 1 LinearLayout containing 1 TextView 25,000   
  13. Inflate 1 LinearLayout containing 6 View objects 100,000   
  14. Inflate 1 LinearLayout containing 6 TextView objects 135,000   
  15. Launch an empty activity 3,000,000  

To write elegant and efficient code for an embedded system, you need to understand exactly what your code is to do. If you really want to allocate an iterator, use foreach for the List. It is your choice, not an unintentional one.

The concepts of Android floating point are introduced here. If there is backup, there is no problem. Know what you want to do. Focus on your greatest enthusiasm, understand your code clearly, and try your best to make it run faster.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.