gpt4 book ai didi

javascript - angularjs计算中的数学错误

转载 作者:行者123 更新时间:2023-12-03 06:33:20 25 4
gpt4 key购买 nike

我正在计算值并将总数除以变量值 (9)。例如:

$scope.wald_costs = Math.round($scope.logistics_costs + $scope.refurbishment_costs + $scope.insurance_costs + $scope.priceful + $scope.t / $scope.$scope.sharable_with)

这将是

$scope.wald_costs = Math.round(1000 + 500 + 4500 + 45000 + 27000 / 9)

假设是$scope.wald_costs = 8666但当我打印 <b>{{wald_costs}}</b> 时,我没有得到正确的输出。相反,我在输出中得到的是这样的 6000450003375

$scope.t = 27000 
$scope.logistics_costs = 1000
$scope.refurbishment_costs = 500
$scope.insurance_costs = 4500
$scope.priceful = 45000
$scope.sharable_with = 9

$scope.wald_costs = Math.round(($scope.logistics_costs + $scope.refurbishment_costs + $scope.insurance_costs + $scope.priceful + $scope.t / $scope.$scope.sharable_with))

我该如何解决这个问题?

最佳答案

试试这个 http://plnkr.co/edit/8ZZY2XtxB2EbB64hWYyn?p=preview

$scope.t = 27000; 
$scope.logistics_costs = 1000;
$scope.refurbishment_costs = 500;
$scope.insurance_costs = 4500;
$scope.priceful = 45000;
$scope.sharable_with = 9;
$scope.wald_costs = Math.round(($scope.logistics_costs + $scope.refurbishment_costs + $scope.insurance_costs + $scope.priceful + $scope.t) / $scope.sharable_with);
alert($scope.wald_costs);

关于javascript - angularjs计算中的数学错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38347955/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com