Hi Lefu,
You should use 100.0 instead of 100
this.vl = 20;
return (double)(this.vl/ *100.0*);
When you use (this.vl / 100) you are dividing Integer to Integer and the result
is Integer, which is 0,
but when you use (this.vl / 100.0) you divide Integer to float, ad the result
is 0.2
Hope it helps,
Saidamin
Lefu Ntho wrote:
Hi guys,
I am trying to divide and given number like this:
this.vl = 20;
return (double)(this.vl/ 100);
expected results would be 0.2 or 0.20 but I get 0.00 which is a pain
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