The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.

Math people, lend me your skills

Jimmy KingJimmy King Registered User regular
edited July 2008 in Help / Advice Forum
I've got to do some work that includes figuring out the pre-VAT cost of an item given the cost of the item including VAT. So, the item in particular is going to be 3.50GBP. With 17.5% VAT, that means pre-VAT cost was about 2.98GBP. Rather than hard coding this 2.98GBP in my app, though, I would much prefer to take that 3.50GBP that I am given as input and determine the pre-VAT value, that way if the 3.50GBP changes at some point in the future (most likely with no one at the company bothering to tell me), I don't have to go back and make changes to the program/configuration to deal with it, it'll just figure out the new pre-VAT value automagically using them fancy math skills I never really developed.

So, basically, I need to be able to solve:
y + (y * .175) = 3.50

Jimmy King on

Posts

  • Atlus ParkerAtlus Parker Registered User regular
    edited July 2008
    totalcost * .851 = pretaxcost

    Give or take

    Atlus Parker on
  • Jimmy KingJimmy King Registered User regular
    edited July 2008
    ah hah. I knew it was going to be something simple like that. Overcomplicating simple things is a common problem for me.

    Thanks man, I appreciate it.

    Jimmy King on
  • Vrtra TheoryVrtra Theory Registered User regular
    edited July 2008
    I don't know if you're worried about the VAT you need to compute with ever changing, but you might want to treat both as inputs, like so:
    vat = 0.175
    
    pretaxcost = totalcost / (1 + vat)
    

    Vrtra Theory on
    Are you a Software Engineer living in Seattle? HBO is hiring, message me.
  • Jimmy KingJimmy King Registered User regular
    edited July 2008
    Thanks vrtra, that does work even better. I was trying to figure out (and getting close to giving up and asking) how the .851 was determined so that I could sort it out later if a different VAT was needed since that is a possibility a month or two down the line, I believe.

    I should really go back to school and take some math classes. I'm one of those developers that mostly does non-math related stuff and so my already lacking math skills have slipped a lot over the years.

    Jimmy King on
Sign In or Register to comment.