当 A、B、C 是这样时输入:A = 27.629999 B = 29.709202 C = -0.070
Then output need to be:
**it should not print anything as 27(=A) matches with {B+ (B*C)} =27 or
(val2+ val3)= 27
下面是我使用 abs 取十进制前的整数值的代码,但它取的是完整整数,如 27.8978 而不是 27
#!/tools/xgs/perl/5.8.5/bin/perl -w
#!/usr/bin/perl
use strict;
use warnings;
my $val1 = abs($A) ;
my $val2 = $B ;
my $val3 = $val2 * ($C) ;
my $val4 = abs ($val2 + $val3) ;
if ($val1 ne $val4)
{
print " $val1 not equal to $val4\n";
}
******************************
Input
when A, B, C are this:
A = 27.629999
B = 29.709202
C = -0.070
Then output need to be:
**it should not print anything as 27(=A) matches with {B+ (B*C)} =27 or
(val2+ val3)= 27
Mean to say while comparing it should consider the integer before decimal.
when A,B,C are this:
A= 27.56
B= 25.678
C= 0
output in this case:
A (27) is not matching with {B+(B*C)} = 25+(25*0) =25
您使用了错误的功能abs()
并没有像您认为的那样做。abs()
将负数转换为正数。您需要int()
删除小数点后的数字部分。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句