in reply to Syntactical changes in Perl 5.8 from 5.6.1

I don't have 5.6.1 available right now, so I can't test it, but what is "%lf" doing? In 5.8.x, 'l' is a size specifier for *integers* (the "d u o x X b i D U O" formats), forcing Perl to interpret them as longs. For %f, you can use the q, L or ll size specifier (quads or long long), but not l.

As for the more general question, differences between 5.8.0 and 5.6.1 are found in the perldelta manual page that comes with 5.8.0. For 5.8.1, the differences between 5.8.0 and 5.8.1 are in its perldelta manual page (and things new in 5.8.0 are found in perl58delta.

Abigail

  • Comment on Re: Syntactical changes in Perl 5.8 from 5.6.1

Replies are listed 'Best First'.
Re: Re: Syntactical changes in Perl 5.8 from 5.6.1
by sweetblood (Prior) on Oct 10, 2003 at 17:11 UTC
    According to 'perldoc -f sprintf'(Perl 5.6.1) the "l" flag used between % and the conversion letter, interprets an integer as C type "long" or "unsigned long".
    I must admit that I am a bit mathematically challenged so, I'm still foggy on the difference between a "floating point number(%f) and a long floating point number(%lf). Any further clarification or documentation would be greatly appriciated.

    Also, I still don't see anything in the perldelta manpage that either deprecates the "%lf" or mentions that there has been a change in syntax.

    Thanks for your assistance!

      Indeed, it interprets an integer as C type "long" or "unsigned long". But %f is a conversion for floats, not integers.

      Also, I still don't see anything in the perldelta manpage that either deprecates the "%lf" or mentions that there has been a change in syntax.
      It actually might be this:
      o The Gconvert macro ($Config{d_Gconvert}) used by perl for stringifying floating-point numbers is now more picky about using sprintf %.*g rules for the conver- sion. Some platforms that used to use gcvt may now resort to the slower sprintf.

      But I'm not sure. And not everything is documented, the people working on Perl are only human!

      Abigail

        And not everything is documented, the people working on Perl are only human!

        I've met a couple of them, they are not what I would characterize as human, perhaps super-human.

        Maybe I should elaborate on these scripts. They were conversions from python, and only accept integers and only return integers. They all look similar except for the operator, and are as follows:

        if ($#ARGV != 1) { die "Usage: div numerator denominator\n" } foreach (@ARGV) { die "Integers only\n" if (/\D+/); } my $tot = sprintf "%lf\n", ($ARGV[0]/$ARGV[1]); $tot =~ s/(\d+)(\.\d+)/$1/; print $tot;

        Perhaps someone can suggest a better way. These were very quicky hammered together to fix a problem with some scripts that rely on them after an OS upgarde.