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

- 11-17-2008, 04:24 PMarnab321decimal calculations?
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? - 11-17-2008, 04:46 PMEranga
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;`

- 11-17-2008, 05:16 PMarnab321
tried that just now. it still returns 1.0. getDuration returns a long

- 11-18-2008, 08:24 AMEranga
Can you show your code here to see?

- 11-19-2008, 01:40 AMfishtoprecords
you need something like:

Code:`float a = (float)(p.getDuration()/1000000.0);`

Floating an integer is still an integer - 11-19-2008, 04:36 AMEranga
Or yes lol, thanks for the pointing my mistake there. I just code in the message box here.