Momen Travolta

Greenhorn

Posts: 8

posted 7 years ago

Can I know how Java deals with 2nd line and 4th line?

I expected this result as something similar is mentioned in the book; but I would like to know -if could be-

Can I know how Java deals with 2nd line and 4th line?

I expected this result as something similar is mentioned in the book; but I would like to know -if could be-

__(1)__due to what the answer is this, and

__(2)__why doesn't the same result appear in C programs.

Campbell Ritchie

Marshal

Posts: 56578

172

Sha Jar

Greenhorn

Posts: 23

posted 7 years ago

They do, unless they're hidden by rounding.

This problem is not programming language specific, it's fundamental to number systems: Using a finite representation, not every number in one number system can be exactly represented in another number system. The conversion errors you've noted are a result of that.

Momen Travolta wrote:why doesn't the same result appear in C programs.

They do, unless they're hidden by rounding.

This problem is not programming language specific, it's fundamental to number systems: Using a finite representation, not every number in one number system can be exactly represented in another number system. The conversion errors you've noted are a result of that.