It is disconcerting that $x2 prints as "258160", but becomes something else when used in a subtraction

I totally agree with you.
The internal hex representation of the double 258160.0 is 410f838000000000, but the internal hex representation of $x2 is 410f838000000001 which should really be printed as 2.5816000000000003e5.
Unfortunately, perl limits the printed output of floats to 15 decimal digits - and, as you can see, if you round $x2 to 15 decimal digits of precision you get 258160.0.

There has been some talk about fixing this in perl-5.26.

Cheers,
Rob

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

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