This misunderstanding is common to many languages not only Perl, because people expect a decimal calculation behind decimal representation.

But 4/25 isn't a number which can be accurately represented in a binary system and rounding errors come into play.

See also Humans have too many fingers


To elaborate further

(4*1000)/25 is an integer but 1000*(4/25) is a float with a very tiny error in the last bits of the mantissa.

Perl will still print this float like an integer because the error is too small.

But after the subtraction the leading zeros in the mantissa will cause a left shift (with adjustment of the exponent).

This means the error shifts out of Perl's tolerance margin and is printed as (decimal) fraction.

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

In reply to Re: Integers sometimes turn into Reals after substraction by LanX
in thread Integers sometimes turn into Reals after substraction by rduke15

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":