hi,
when i try this: float a=p.getDuration()/1000000;
System.out.println("a="+a+" actual="+p.getDuration());
p.getDuration() is a number like 1791800
so, a is expected to be 1.7918.
but why does is come as 1.0?
Printable View
hi,
when i try this: float a=p.getDuration()/1000000;
System.out.println("a="+a+" actual="+p.getDuration());
p.getDuration() is a number like 1791800
so, a is expected to be 1.7918.
but why does is come as 1.0?
Is that getDuration() return an int value? In that case you have to cast it as a float.
Code:float a = (float)p.getDuration()/1000000;
tried that just now. it still returns 1.0. getDuration returns a long
Can you show your code here to see?
you need something like:
Your use of an integer in the denominator causes the division of "p.getDuration()" to be done as an integer.Code:float a = (float)(p.getDuration()/1000000.0);
Floating an integer is still an integer
Or yes lol, thanks for the pointing my mistake there. I just code in the message box here.