当我做这样的事情
int test = 5 + 3 * (4 - 1) / 2;
Run Code Online (Sandbox Code Playgroud)
我得到9.我怀疑这是因为int舍入.但是,当我这样做
float test = 5 + 3 * (4 - 1) / 2;
Run Code Online (Sandbox Code Playgroud)
我也得到9.然而,当我这样做
float test1 = 5;
float test2 = 4.5;
float test = test1 + test2;
Run Code Online (Sandbox Code Playgroud)
测试最终输出9.5.有人可以解释这背后的逻辑吗?为什么我在第二个例子中得不到9.5?谢谢.
所以,我有以下代码:
var clicks = 0; // click counter
// Make sure this only runs on facebook
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
if (tab.url.indexOf("facebook.com") > -1) {
chrome.pageAction.show(tabId);
}
});
// Called when the user clicks on the page action.
chrome.pageAction.onClicked.addListener(function(tab) {
if (clicks == 0) {
chrome.pageAction.setIcon({path: "dontlike.png", tabId: tab.id}); // Update icon
chrome.pageAction.setTitle({title: "idontlike", tabId: tab.id}); // Update title
chrome.tabs.executeScript({ // Hide like buttons
code: 'var like = document.getElementsByClassName("UFILikeLink"); for (index = 0; index < like.length; ++index) { like[index].style.display="none"; }' …Run Code Online (Sandbox Code Playgroud)