aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes loss of pression Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "loss of pression" Watch "loss of pression" New topic
Author

loss of pression

satya uppaluri
Greenhorn

Joined: Oct 16, 2002
Posts: 21
hi,
I have a lose of precision problem.

why this code is loosing precision?

double f = 4.35;
return (int)(100 * f);

Why this call is returning 434.
I can see that 100 * f is giving a value of 434.99999999994

but I can not understand why?

Thanks
Satya
vivekkumar sharma
Ranch Hand

Joined: Dec 21, 2005
Posts: 70
Originally posted by satya uppaluri:
hi,
I have a lose of precision problem.

why this code is loosing precision?

double f = 4.35;
return (int)(100 * f);

Why this call is returning 434.
I can see that 100 * f is giving a value of 434.99999999994

but I can not understand why?

Thanks
Satya


why r u casting result to int ??
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: loss of pression
 
Similar Threads
Integer assignment
Loss of precision in primitives
Widening Conversion
Precision?
assign float to int ??