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 ...
- 02-26-2008 #1Linux 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 issueSwitched to Scripting
- 02-26-2008 #2
When I run these Perl statements, the script dies on the first line. It says:
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.Code:Illegal division by zero at ./1.pl line 3.
--
Bill
Old age and treachery will overcome youth and skill.
- 02-26-2008 #3Linux Newbie
- Join Date
- Jan 2008
- Posts
- 114
thanks, I used if condition not to fall in infinite situation.
Switched to Scripting


Reply With Quote