in reply to Re: Converting a string to a real numeric value - what's faster?
in thread Converting a string to a real numeric value - what's faster?

Thanks!
What I learn from that is: if i am handling non-floating-point values, it's a bit more elegant and possibly a tick faster (one iteration less, 1-b vs 1-c) to use int(), otherwise the +0 trick isn't that much of a hack it seems to be.
  • Comment on Re^2: Converting a string to a real numeric value - what's faster?

Replies are listed 'Best First'.
Re^3: Converting a string to a real numeric value - what's faster?
by mwah (Hermit) on Sep 17, 2009 at 10:04 UTC
    if i am handling non-floating-point values, it's a bit more elegant ... to use int()

    .. if it's worth the typed characters at all ;-)

    As you said before, Perl will convert the string into a number internally if the string isn't already converted (IV-Flag not set) and if the string is used in a numerical context.

    Of course, when using Perl-Guts (XS), you have to worry.

    regards

    mwa