Is it better to set the whole expression or just a variable like

I use floats for some graphic games for Android Java, but the trigger of the Math library performs all double returns, so I have to use them explicitly.

I understand that floats process faster than double, and I don't need high-precision answers.

eg. what's better:

screenXf = (float) (shipXf + offsetXf * Math.sin(headingf) - screenMinXf);

or

screenXf = shipXf + offsetXf * (float) (Math.sin(headingf)) - floatScreenMinXf;

I suppose other questions will be "how can I test this on an emulator without any other factors (like PC services) confusing the problem?" and "anyway, will it be different on other equipment?"

God there are three questions. Life is never simple: - (

-Frink

+3
source share
2 answers

FloatMath.sin().

FloatMath

, , Math. float , double.


android:

http://developer.android.com/guide/practices/design/performance.html#avoidfloat


...
float double . , . , , , .

@fadden, , , :

Android API ?

FPU , - . - Android FloatMath, java.lang.Math, float double.

Android- FPU , -, , . ( " " G1, , .)

( "... " ) , , , " ", .

+1

HW. , , , i386.

, , HW HW . , http://code.google.com/p/caliper/ .

+1

Source: https://habr.com/ru/post/1790088/


All Articles