Results 1 to 3 of 3
- 06-29-2012, 04:26 AM #1
Member
- Join Date
- May 2012
- Posts
- 15
- Rep Power
- 0
Double keeps rounding to integer?
I'm working with an audiostream, using the clip.getMicrosecondPosition() method to find out how many microseconds have passed.
When left alone, the microsecond value is dead on precise - but when I try to multiply it and convert to to a decimal (double), it always rounds to the nearest integer.
Here's the code:Java Code:double seconds = clip.getMicrosecondPosition() / 1000000;
Help would be much appreciated!
- 06-29-2012, 04:42 AM #2
Re: Double keeps rounding to integer?
The expression to the right of the = is all int values so int rules are used. Change the divisor to double by adding a .0D to the end to get a floating point value.
If you don't understand my response, don't ignore it, ask a question.
- 06-29-2012, 06:12 AM #3
Member
- Join Date
- May 2012
- Posts
- 15
- Rep Power
- 0
Similar Threads
-
convert integer to double
By himanwish in forum New To JavaReplies: 4Last Post: 03-17-2011, 02:55 AM -
Adding an integer to a double?
By tokoolio in forum New To JavaReplies: 5Last Post: 01-17-2011, 07:57 PM -
rounding double to two decimal places
By javaMike in forum Advanced JavaReplies: 15Last Post: 03-10-2010, 01:04 AM -
How to extract integer value out of a double value?
By javaexplorer in forum AWT / SwingReplies: 4Last Post: 01-16-2010, 06:32 AM -
rounding a double in a number of significant numbers
By rikribbers in forum Advanced JavaReplies: 2Last Post: 10-27-2008, 04:35 PM
Bookmarks