Results 1 to 6 of 6

Thread: Very basic maths

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2002
    Location
    Australia
    Posts
    108

    Very basic maths

    if I had a base value, which was marked up by say, 10%, then was marked up again by 15%, to give a final value, what calculation would work to work out the base value if only given the final?

    And what would be the best way to set it up to allow for variations in those percentages?

    Thanks

  2. #2
    Hyperactive Member
    Join Date
    Sep 2001
    Posts
    396
    base_value =(100/110)*(100/115)*final_value

  3. #3
    Hyperactive Member
    Join Date
    May 2002
    Location
    Chicago
    Posts
    271
    Basically, when you increase a number by some percentage you're actually multiplying by 1 + the percentage like this:
    A * (1 + some%) = B
    If A = 100 and the percent to add = 10% (10%=.1) then
    100 * (1 + .1) = B
    100 * 1.1 = B
    B = 110
    so to determine A given B and the percent increase of A you would use:
    A = B / (1 + .1)
    A = 110 / 1.1
    A = 100
    This is demonstrated in the following code where the base number is increased by multiple percentages, just place 2 command buttons on a form and paste this code.
    Code:
    Option Explicit
    Dim MyBaseNumber, MyNewNumber
    Dim PercentArray()
    
    Private Sub Form_Load()
      'change these values to suit your needs
      ReDim PercentArray(2) 'holds percent multipliers (as many as needed)
      MyBaseNumber = 120
      PercentArray(0) = 0.1 '10%
      PercentArray(1) = 0.15 '15%
      PercentArray(2) = 0.05 '05%
    End Sub
    
    Private Sub Command1_Click()
      Dim i As Integer
      Dim MsgTemp As String
      MyNewNumber = MyBaseNumber
      'the following loop creates a new number based on the percent array
      For i = 0 To UBound(PercentArray)
        MyNewNumber = MyNewNumber * (1 + PercentArray(i))
        MsgTemp = MsgTemp & " + " & PercentArray(i) * 100 & "%"
      Next
      MsgBox MyBaseNumber & MsgTemp & " = " & MyNewNumber
    End Sub
    
    Private Sub Command2_Click()
      Dim i As Integer
      Dim MsgTemp As String
      
      If Len(MyNewNumber) = 0 Then
        MsgBox "Click Command1 first."
        Command1.SetFocus
        Exit Sub
      End If
      MyBaseNumber = MyNewNumber
      'the following loop recreates the base number
      For i = UBound(PercentArray) To 0 Step -1
        MyBaseNumber = MyBaseNumber / (1 + PercentArray(i))
      Next
      MsgBox "The base number is: " & MyBaseNumber
    End Sub
    Sometimes what you're looking for is exactly where you left it.

  4. #4
    Addicted Member
    Join Date
    Feb 2001
    Posts
    198
    This is when you find out what a 'rounding error' is.
    We had to try to create pre-tax costs from a group of tax-included figures.
    Our accoutant suggested that this is why so many shop prices ended in .99

  5. #5
    Junior Member
    Join Date
    Jun 2002
    Location
    Urbana, IL
    Posts
    24
    the .99 thing is actually just a marketing scam to make you think it is cheaper. When people se $19.99 flash up as a price it just seems cheaper then $20.00 to most people. It also allows them to say "for under twenty dollars".

    Quick brain teaser. What TV character invented the 99 cent coin, but had it rejected by the governemnt beause taxes make it pointless.

  6. #6
    Addicted Member
    Join Date
    Feb 2001
    Posts
    198
    >marketing scam
    Oh yeah, I know that, our accountant did say that with a smile, but when you try to find what the original cost of several thousand items was when the data you're given contains 17.5% tax (which you know was rounded in the customer's favour), you know that you are only going to get a correct answer 1 in 47 times - 1 (smallest denomination coin) multiplied by 46/47*several thousand items, amounts to a noticeable amount of money.
    Luckily we found another feed that gave us the pre-tax costs.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width