gpt4 book ai didi

javascript - Jquery/Javascript 数学 : Why are these two 1 line math problems not giving the same answer?

转载 作者:行者123 更新时间:2023-11-30 07:47:13 27 4
gpt4 key购买 nike

这两道数学题不应该给出相同的答案吗?括号/括号先完成,对吗?所以它应该将它们全部相加,然后除以 2,然后减去 10。下面的第二个答案是一个给出了我需要的正确值,另一个给出了一个很长的路要走的值。

    var pleft = $(this).offset().left + ($(this).width() /2) - ($("#question-wrapper").width() / 2) - 10;

var pleft = (($(this).offset().left + $(this).width() + $("#question-wrapper").width()) / 2) - 10;

最佳答案

var x = $(this).offset().left;
var y = $(this).width();
var z = $("#question-wrapper");

var pleft = x + (y/2) - (z/2) - 10

var pleft = ((x + y + z) / 2) - 10

希望这有助于消除差异。

关于javascript - Jquery/Javascript 数学 : Why are these two 1 line math problems not giving the same answer?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3966595/

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