Slashdot Mirror


Rounding Algorithms

dtmos writes "Clive Maxfield has an interesting article up on PL DesignLine cataloging most (all?) of the known rounding algorithms used in computer math. As he states, "...the mind soon boggles at the variety and intricacies of the rounding algorithms that may be used for different applications ... round-up, round-down, round-toward-nearest, arithmetic rounding, round-half-up, round-half-down, round-half-even, round-half-odd, round-toward-zero, round-away-from-zero, round-ceiling, round-floor, truncation (chopping), round-alternate, and round-random (stochastic rounding), to name but a few." It's a good read, especially if you *think* you know what your programs are doing."

5 of 279 comments (clear)

  1. Don't you just... by TedTschopp · · Score: 0, Offtopic

    Double it and add Thirty, or is that the metric conversion for Beer?

    --
    Fantasy remains a human right; we make in our measure and in our derivative mode... -- JRR Tolkien
    1. Re:Don't you just... by baadger · · Score: 1, Offtopic

      I know your comment is both off topic and just plain silly but the correct conversion between deg F and deg C is F=(C*1.8)+32

    2. Re:Don't you just... by brunson · · Score: 0, Offtopic

      And you have no idea who Bob and Doug McKenzie are.

      Please stop posting until you acquire a sense of humor.

      --
      09F911029D74E35BD84156C5635688C0
      Jesus loves you, I think you suck
  2. the best rounding algorithm by circletimessquare · · Score: 0, Offtopic

    is the one used by richard pryor's character in superman iii to steal all of the half pennies from his company's payroll and become fabulously rich

    rip dude

    --
    intellectual property law is philosophically incoherent. it is your moral duty to ignore it or sabotage it
  3. Re:Accounting Software by renehollan · · Score: 0, Offtopic
    "Yeah, because the US tax laws are a paragon of fairness, transparency, and virtue."

    While the U.S. tax code might be rather baroque, my individual experience with the IRS has been far better than any experience I had with Revenue Quebec -- and I've had hideously complex tax returns sometimes requiring the services of a tax accountant at a cost of $700 to file 1 inch thick returns.

    Before y'all scream "See, I told you so!" note that the complexity was of my doing: Moving expenses are handled differently in the U.S. than Canada, and when I returned to the U.S. after working for a Canadian employer that had paid my relo expenses and required two years employment or a refund of a prorated portion of those expenses, I used complex tax treaties to make them deductible against U.S. taxes in the year I refunded them.

    In Canada, moving expenses are neither a taxable benefit when reimbursed, nor a deduction when not. But, the situation in the U.S. is different: reimbursed moving expenses (for purposes of employment, satisfying the time and distance tests) are taxable, but are also deductible to the extent they were used to pay for elegible moving expenses related to employment. The practical upshot is that if you pay net moving expenses related to a new job, you can claim them as an itemized deduction against income in the year you move, or the year you pay them. Refunding reimbursed moving expenses makes them deductible in the year you refund them -- if you are subject to U.S. taxes during the period of employment.

    For a U.S. citizen, this is trivial: they are always taxed on worldwide income, regardless of where they reside, though there is a blanket $US70k exemption for periods of residency outside the U.S. exceeding one calendar year. But, I am a Canadian, not U.S. citizen, and failed to meet the U.S. Tax residency test when i was in Canada.

    This is where the tax treaties come in.

    The Canada-U.S. Tax Treaty basically means that a Canadian, in the U.S., can't be taxed more than an American in similar circumstances. It also says that a Canadian can not be subject to greater U.S. taxes than a different foreigner under similar circumstances. This is where the U.S.-Germany Tax Treaty comes in: A German can't be taxed worse, anywhere in the world than an American in similar circumstances. So, a German, in Canada, can't be subject to greater U.S. taxes than an American in Canada would, and thus a Canadian, in Canada, can't be subject to greater U.S. taxes than that German, or an American.

    The practical upshot is that a Canadian, in Canada, can elect to subject themselves to U.S. taxation as if they were an American in Canada. Generally, there is little benefit to do this, because all you'd do is use the FEIE to excempt the first US$70k (or is it $80k now?) of employment income, and/or use the FTC to offset U.S. tax owing by Canadian tax paid (which will likely be higher), yielding the same result as not subjecting one's self to U.S. taxes in the first place: there are few U.S. refundable tax credits. (One is the child tax credit, which, by treaty, is not taxable in Canada, because it is not taxable in the U.S. so Canadians with kids can pull a fast one on Uncle Sam if they have a good tax accountant).

    Sometimes, however, if you have U.S. source income (you just got a NAFTA visa), it can pay to ammend one's U.S. return for prior years in Canada, and subject one's self to U.S. tax for them (which should be a wash, as noted above) in order to get current benefits relating to the earning of that prior-years income, i.e. a deduction for the moving expenses paid to return to Canada to earn it.

    Of course, if you do this, you have to declare all foreign source income. That means gains on the sale of Canadian property (which might be exempt, but gains on the discharge of a foreign mortgage with cheaper U.S. dollars than when the mortgage was written aren't), bank interest, etc. You also get to deduct mortgage interest,

    --
    You could've hired me.