Sunday, 11 August 2013

Floating Point is not correct

Floating Point is not correct

I am getting a value from server that is not containing any Floating point
let say its 1234 and have to cvonvert it in Floating value with 2 decimal
point like 12.34.
Right now what i am doing is getting value storing it in float that
convert the current value 1234 to 1234.0 after that doing this
tempB=Math.floor(tempB)/100.0;
DecimalFormat df = new DecimalFormat("###.##");
RewardsBalance=df.format(tempB);
But with this i m having an issue that when i have value such that 1230 it
results in 12.3 not that 12.30 but when i have value 1234 it gives the
desired result that is 12.34 so what step i m missing any clue

No comments:

Post a Comment