Why are there so many floats in the Android API?

前端 未结 5 1112
梦谈多话
梦谈多话 2021-02-07 09:46

The default floating point type in Java is the double. If you hard code a constant like 2.5 into your program, Java makes it a double automatically. When you do a

5条回答
  •  耶瑟儿~
    2021-02-07 10:19

    Weird. Designing for Performance in the guide seems to say "....The common practice on desktop systems is to use floating point freely......so all operations on "float" and "double" are performed in software...." at http://developer.android.com/guide/practices/design/performance.html#avoidfloat

    This may make some sense: "....Instructions aren't gratuitously limited to a particular type. For example, instructions that move 32-bit register values without interpretation don't have to specify whether they are moving ints or floats....." at http://www.netmite.com/android/mydroid/dalvik/docs/dalvik-bytecode.html

提交回复
热议问题