in reply to Q: NaN again

Please explain what problem you're trying to solve. We can probably help you find an easier way to solve it.

--
<http://dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

Replies are listed 'Best First'.
Re^2: Q: NaN again
by kai (Initiate) on Oct 19, 2006 at 12:04 UTC
    Problem in filtering of user input.
    For example. User try to make bid at auction, and enter NaN in "price" field. All standart methods like: $price = sprintf("%.2f", $price); return me NaN But it not so bad. Really bad is:
    if ($price > $user_money) { return "You have not enough money". }

    Will fail for NaN. I found about 30 "nan holes" in my code after 5.8.4, and I suppose, I found not all of it.

    P.S. Sorry for my bad english.

      Then, as you say, your problem is with filtering user input. When you recieve input from a user, you need to check that it is a valid number and reject (or ignore) it if it isn't.

      --
      <http://dave.org.uk>

      "The first rule of Perl club is you do not talk about Perl club."
      -- Chip Salzenberg

        I have a huge amount of old code. About ten megabytes. I can't check all. So, all I need to know - how to disable NaN autosupport in perl 5.8.4+ for amd64 :-)
      P.S. Sorry for my bad english

      That's ok ... no need to apologise for that. But it would really help if you could provide a complete (and simple) perl script that demonstrates one of the problems you are having.

      Support for NaN's does not exist in perl for all architectures/platforms. It would help us to know which architecture and platform you're running.

      Cheers,
      Rob
        web # perl -e '$a="nan"; print sprintf("%.2f",$a)' nan web # perl -v This is perl, v5.8.8 built for x86_64-linux ----- For Win32: This is perl, v5.8.4 built for MSWin32-x86-multi-thread perl -e "$a='nan'; print sprintf('%.2f',$a)" 0.00