Double manipulation trouble
<p>Suppose n is a Double type variable . </p>

<pre><code>double right=n-(Math.ceil(n)-1);

//Here I am trying to get the right part of the number.
</code></pre>

<p>Now if <code>n=1234.78</code></p>

<p>then <code>right=0.7799999999999727</code></p>

<p>why not <code>.78</code>? </p>

<p>and when</p>

<pre><code>n=1234.89
</code></pre>

<p>then <code>right=0.8900000000001</code></p>

<p>why not <code>89</code>? and why not <code>9999</code>... here instead of <code>000000</code>....? </p>

<p>Now suppose I want to find the sum of digits in right..Like in my example for 1234.89 its 8+9=17 or 1234.781 its 7+8+1-16. So then ?what should I do?</p>

<p>But I can't do it using floating point arithmatic?Like </p>

<pre><code>double temp=0.0; 
while(right&gt;0) 
{ 
right=rigth*10; 
temp=Math.floor(right); 
right=right-temp; 
suml+=temp; 
} 
</code></pre>

<p>in kind of a way I mentioned above?
I am new to java. please explain my problem. It would be a great help for me. Thank you.</p>
