Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert float to int : android [duplicate]

Tags:

java

float NormValue = value*80 ;
float color = Color.argb(0xFF, NormValue, 0, 0);

This is a part of my code. This variable (NormValue) stores the result in float . But in second line i cannot use this variable since it has to be converted to int. How can i do it. Any help?

like image 872
Aswathy Avatar asked Dec 04 '13 11:12

Aswathy


1 Answers

Try this..

No need to typecast float to int just use Math.round()

float NormValue = value*80 ;
float color = Color.argb(0xFF, Math.round(NormValue), 0, 0);
like image 143
Hariharan Avatar answered Sep 29 '22 15:09

Hariharan