Find the answer to your Linux question:
Results 1 to 3 of 3
Print statement is not executing and $inst_percent is not getting initialized looks like due to infinite value:- my $tinst_percent = (25 / 0 )*0; $inst_percent = $inst_percent - int($tinst_percent+0.5); print ...
  1. #1
    Linux Newbie
    Join Date
    Jan 2008
    Posts
    114

    arithmetic operation for infinite value in Perl

    Print statement is not executing and $inst_percent is not getting initialized looks like due to infinite value:-

    my $tinst_percent = (25 / 0 )*0;
    $inst_percent = $inst_percent - int($tinst_percent+0.5);

    print "After Calculation $inst_percent";

    please help me in resolving the issue
    Switched to Scripting

  2. #2
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    When I run these Perl statements, the script dies on the first line. It says:
    Code:
    Illegal division by zero at ./1.pl line 3.
    So don't divide by zero. Perl doesn't define a lot of arithmetic for infinite values. If there's a possibility you might be dividing by zero, set a flag which indicates to your program that you tried to divide by zero, and do any special case operations you may wish to do, later in the script.
    --
    Bill

    Old age and treachery will overcome youth and skill.

  3. #3
    Linux Newbie
    Join Date
    Jan 2008
    Posts
    114
    thanks, I used if condition not to fall in infinite situation.
    Switched to Scripting

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...