On Apr 9, 9:26 pm, Lefu Ntho <[email protected]> wrote:
> Hi guys,
>
> I am trying to divide and given number like this:
> this.vl = 20;
This is an integer.
>  return  (double)(this.vl/ 100);
When you divide an integer by another integer, the result is an
integer, so 0 here
>
> expected results would be 0.2 or 0.20 but I get 0.00 which is a pain
Perfectly normal, double(0) = 0.00

So you should define one of the element of the division as double or
float, then you will get the expected result.
See: http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.2
for reference about integer type
and:
http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#239829
for division operation.

Michèle
> in my neck, please help.
>
> Thank you
> Lefu

-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en

To unsubscribe, reply using "remove me" as the subject.

Reply via email to