I want to round the numbers like this:  Value   Expected 0,523%  1% 2,235%  2,5% -0,081% -0,5% -1,081% -1,5%   How can I do this with JavaScript?  Solution:    static round (num) {     const abs = Math.abs(num);     const sign = num &lt; 0 ? -1 : 1;     return sign * (abs % 1 &gt; 0.5 ? Math.ceil(abs) : Math.floor(abs) + 0.5) } }   I used Excel for it =round(Value/Granularity)*Granularity but I tried it in JavaScript not working.    static calc(num){     const granularitiy = 0.00005;     let calc = Math.round((num / granularitiy)) * granularitiy;     return calc;   }   My granularity value is 0.00005;
While working on a project, I came across a JS-script created by a former employee that basically creates a report in the form of  Name : Value Name2 : Value2   etc.  The peoblem is that the values can sometimes be floats (with different precision), integers, or even in the form 2.20011E+17. What I want to output are pure integers. I don't know a lot of JavaScript, though.  How would I go about writing a method that takes these sometimes-floats and makes them integers?
Proper capitalization of commonly used acronyms and initialisms I was always under impression, that acronyms ought to be written all caps. However reading  site very often I see some of the common acronyms written as proper names (first cap). For example "Nato" instead of "NATO".   I know that BBC is quite strict in proper English usage, so what would be the reason behind this? Topology: Proof that a finitely generated cone is closed How to find perpendicular vector to another vector? How do I find a vector perpendicular to a vector like this: $$3\mathbf{i}+4\mathbf{j}-2\mathbf{k}?$$ Could anyone explain this to me, please?  I have a solution to this when I have $3\mathbf{i}+4\mathbf{j}$, but could not solve if I have $3$ components...  When I googled, I saw the direct solution but did not find a process or method to follow. Kindly let me know the way to do it. Thanks. Pandas Merging 101 How to connect Nokia Lumia 730 to Ubuntu 15.04? My Nokia Lumia 730 (WP8.1) is not getting detected on Ubuntu 15.04.  Can anybody tell me how to fix this? hierarchical retreival of records in postgresql I have two checkboxes in a lightning component, when we click on the first checkbox it marks true to the other checkbox, it works well only with the UI tags but doesn't work when I convert it to lightning tag  &lt;ui:inputCheckbox aura:id="box3" change="{!c.selectAll}"/&gt;  &lt;ui:inputCheckbox aura:id="boxPack" value=""                                                          change="{!c.checkboxSelect}"/&gt;   below are the lightning tags  &lt;lightning:input type="checkbox" aura:id="box3" onclick="{!c.selectAll}"/&gt;  &lt;lightning:input type="checkbox" aura:id="boxPack" value=""                                                          onclick="{!c.checkboxSelect}"/&gt;   controller  checkboxSelect: function(component, event, helper) {         // get the selected checkbox value           var selectedRec = event.getSource().get("v.value");         // get the selectedCount attrbute value(default is 0) for add/less numbers.          var getSelectedNumber = component.get("v.selectedCount");         // check, if selected checkbox value is true then increment getSelectedNumber with 1          // else Decrement the getSelectedNumber with 1              if (selectedRec == true) {             getSelectedNumber++;         } else {             getSelectedNumber--;         }         // set the actual value on selectedCount attribute to show on header part.          component.set("v.selectedCount", getSelectedNumber);     },      selectAll: function(component, event, helper) {         //get the header checkbox value           var selectedHeaderCheck = event.getSource().get("v.value");         // get all checkbox on table with "boxPack" aura id (all iterate value have same Id)         // return the List of all checkboxs element          var getAllId = component.find("boxPack");         // If the local ID is unique[in single record case], find() returns the component. not array            if(! Array.isArray(getAllId)){             if(selectedHeaderCheck == true){                  console.log('true');                 component.find("boxPack").set("v.value", true);                 component.set("v.selectedCount", 1);             }else{                 component.find("boxPack").set("v.value", false);                 component.set("v.selectedCount", 0);             }         }else{             // check if select all (header checkbox) is true then true all checkboxes on table in a for loop               // and set the all selected checkbox length in selectedCount attribute.             // if value is false then make all checkboxes false in else part with play for loop              // and select count as 0              if (selectedHeaderCheck == true) {                 for (var i = 0; i &lt; getAllId.length; i++) {                     component.find("boxPack")[i].set("v.value", true);                     component.set("v.selectedCount", getAllId.length);                 }             } else {                 for (var i = 0; i &lt; getAllId.length; i++) {                     component.find("boxPack")[i].set("v.value", false);                     component.set("v.selectedCount", 0);                 }             }          }        }, Changing order of features in shapefile I haven't filed 2020 taxes yet. On my last return (2019) my adult daughter was on my return as a dependent. When I file 2020, I will not put her on my return as a dependent, because she finished college in 2019. I had her file her 2020 return early this year so she would be sure to get a stimulus check in case they did another one (I assumed they would exclude adult dependents as they had with previous stimulus payments). Today, she got the $1,400 deposited to her account by the Treasury. However, I was surprised to see $4,200 deposited to my account, when I expected only $2,800 (for me and my wife). They paid for my daughter twice, $1,400 to her (based on her 2020 return) and $1,400 to me (based on my 2019 return that showed her as a dependent). They have the social security numbers, so I assumed the IRS and Treasury would have figured this out. I have searched and searched, but am unsure whether this overpayment will be clawed back or not. I can't even find a mechanism for returning it (and getting credit for doing that if they later do say I owe it to them). I've read if your 2019 income made you eligible, but your 2020 income (if you file after the stimulus) would have made you ineligible, they won't claw back the stimulus they sent. Stimulus money for people that died between the tax return and the stimulus disbursement does have to be returned to the treasury. I can't find guidance for our situation. There must be a fair number of people with college kids that have the same scenario. This question  seems at first to ask the same thing, but it doesn't include the key point of overpayment by the Treasury. Looking for a book, wormhole, space ship Crash landing From what I remember of the book:   A spaceship goes through a wormhole (I think) and crash lands on a planet They salvage what they can from the ship and build a castle on a mountain, cutting the stone with the lasers from the crashed ship The crew develop some sort of powers, the captain (She) seems to develop some sort of Precognition The planet's inhabitants where men rule and women are second class citizens Some women escape to the crew's castle so they can be equal citizens After they build the castle the crew fight the inhabitants the that came to attack them   What is the name of this book? Do Stack Exchange sites allow editing of comments and posts from other users? Possible Duplicate:         Is this normal behavior in Stack Exchange sites that after just signing up one can edit not only his/her own comments / posts, but also others' comments / posts?  If so, then the Q&amp;A does not look safe to me. Imagine someone maliciously modifying a post and bringing bad reputation on a Q&amp;A member.  Can you check this and perhaps fix it? How to access a clicked URL in a URL handler application created in Automator I'm currently trying to modify the default URL handling behavior in OS X. I would like, when clicking on any link outside of a web browser, to copy this URL to the pasteboard instead of opening it in the default web browser – for instance, clicking a link in a Skype conversation should copy this URL to the OS X pasteboard instead of opening it in Firefox (which is currently my default web browser).  I have thought about solutions, but I’m currently unable to implement one. If I can create an application that puts URLs into the pasteboard that are sent to it, and can set this application as the default web browser, I would be able to achieve my goal.  I created an application with Automator that executes the shell command pbcopy and have set this application as my default web browser, but I didn’t get the expected result. I did some testing and I can confirm that the application runs on clicking on a link, however, I cannot get the URL passed to the application / shell script. I tried both stdin or a passed argument, but without success.  Is there a way for an application created with Automator to retrieve a clicked URL and send it to pbcopy, when that application is set as a (default) handler for URLs?  Alternatively, is there a better way to create a fake web browser that takes the input and puts it in the pasteboard than Automator? Or is there any other way that I can achieve my goal without a custom application / script? Self-deletion and un-deletion without any changes should reinstate the original close/delete votes Are there rules for falling in water vs. diving vs. just jumping in for various depths of water? Automatically put PGFPlots xtick scale label in x axis label I have an Excel file containing data collected over many years as latitude and longitude coordinates for archaeological sites. How can I import it into QGIS as a new layer? How to start git-gui? What happens if I do not honor a futures contract? I have little knowledge about futures contracts. The recent negative price of crude oil spurred my curiosity about this stuff.   I read this post about .  According to this post, when I buy a futures contract, I enter into a contractual agreement to buy some commodity on some future date, and I only need to pay a 2% initial margin.   Suppose the price of the commodity does not fluctuate but I change my mind and decide not to buy the commodity at maturity. What punishment could be exerted on me?   I do not want the 2% initial margin back because that is a little money compared to the real value of the commodity. If there is no extra penalty, it would be unfair for the seller — imagine the seller transports 1000 barrels of crude oil to your front door and you say "I do not need it any more, please take it away, thank you!"  Update: I did more research about this and have more questions.  If I buy a futures contract at $10 and the price of the contract drops to -$37 at the last trading day, at which price should I buy the commodity at the delivery day, $10 or -$37?   There seems not just one contract I enter into when I buy a futures contract: the original futures contract between me and the seller of the commodity(or the exchange?), the contract between me and my brokerage, the contract between the brokerage and the exchange. I'm not clear about the exact entities of each contract and the obligations involved in each contract. The contracts seem contradictory with each other, e.g., my brokerage may forcefully sell my futures contract if my account balance is not enough, which will prevent me from fulfilling the obligations in the futures contract, i.e., receiving the commodity on future date.  If I(or an institutional trader) trade directly (not via a brokerage) with an exchange(does CME accept individual traders?), does the exchange have the rights to forcefully sell my contracts at the last trading day at any price or close my position at the settlement price(say -$37)? If the exchange does so thus letting me own $5,000M to it, is it more justice for me to sue the exchange rather than let the exchange sue me? If I could hold the position, the loss caused by my not executing the delivery/receipt of the commodity may be less than $5,000M. Of course, the loss will be determined by the court, not by the exchange according to the settlement price formed by itself or a few possible conspirators. Salesforce lightning get current users username How I would go about getting the current users username or first and last name?  I have been looking at this for the last couple of hours - I was just wondering how I would go about getting their name and then displaying it on the page.  For example the current user is 'John Smith' and in the lightning component I want to output John Smith's name like:     Welcome to our community John Smith! Charts from numbers not dynamically updating in Pages/Keynote I have the 2015 versions of Pages, Numbers, and Keynote on Yosemite.  I created a chart in numbers and then copied it to Pages or Keynote. I then want to be able to change the data in Numbers and see the chart updated in Pages or Keyonte. However, I don't see an option to "refresh".  Is there a way to dynamically link Numbers to Pages or Keynote?