Hi Monks,

I have a question regarding Perl's numeric type, and how (I assume) it simplifies the value before storing/printing them.

For example:

use warnings; my $foo = 50.0; warn $foo;

would display 50, rather than 50.0. I'm interested in knowing if this is always the case (can I rely on this behaviour of simplifying the number?), where can I read more about this if it is documented. I tried searching for more information in https://perldoc.perl.org/perlnumber but I couldn't find anything specific to this.

I am only interested because I find this an easy way to remove trailing decimal zeroes, and if I can get away with not using sprintf then that would be great.


In reply to Perl 5 numeric type and simplifications by pango

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.