我的下面的脚本有问题,如何使多重结果等于1332521814089765。
#!/usr/bin/perl
my $divide = 1332521814089765/1332521809;
my $results1 = int $divide;
print "After Divide: $results1 \n";
my $multiplication = $results1*1332521809;
my $results2 = $multiplication;
print "After Multiplication: $results2 \n"; #How to make multification results equals to 1332521814089765
搜索并在此处测试结果但仍未达到我预期的结果
my $divide = 1332521814089765/1332521809;
my $multiplication = $divide*1332521809;
my $results = $multiplication/10;
print "My Results: $results\nExpect Results: 1332521814089765\n";
答案 0 :(得分:2)
1000000 * 1332521809等于1332521809000000.为什么你会期待1332521814089765?
也许你正在乘以错误的数字,也就是说你打算使用
my $multiplication = $divide*1332521809;
而不是
my $multiplication = $results1*1332521809;
另一种可能性是你试图找到
的反函数$y = int($x/$k)
很遗憾,没有,因为有$x
的多个值可以提供相同的$y
。
int(1332521809000000/1332521809) = 1000000
...
int(1332521814089764/1332521809) = 1000000
int(1332521814089765/1332521809) = 1000000
int(1332521814089766/1332521809) = 1000000
...
int(1332523141521808/1332521809) = 1000000