Announcement

Collapse
No announcement yet.

calculations with currency

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Michael Mattias
    replied
    In the example given it's moot, since no intermediate value requires more than 4 positions after the decimal, meaning you never get into rounding at all.

    FWIW, I use CUR for all money stuff and never have any problems.

    [added]
    Except for the division.


    MCM
    Last edited by Michael Mattias; 24 Mar 2009, 06:48 PM.

    Leave a comment:


  • John Gleason
    replied
    Erich, do you have PB 9/5? If so, then you can use eg. 0.03## to convert them to EXT.

    Leave a comment:


  • Bob Zale
    replied
    EXT would be the best choice.

    Leave a comment:


  • Erich Schulman
    started a topic calculations with currency

    calculations with currency

    Code:
    FUNCTION CalcMatch(A1 AS STRING, B1 AS STRING) AS STRING
    LOCAL cA1,cB1,cMatch AS CURRENCY
    
        cA1 = VAL(A1) : cB1 = VAL(B1)
    
        'matching scenarios ladder up
        IF cB1 / cA1 <= 0.03# THEN '1st matching scenario
            FUNCTION = B1
            EXIT FUNCTION
        END IF
    
        IF cB1 / cA1 <= 0.05# THEN '2nd matching scenario
            cMatch = cA1 * 0.03# + cA1*(cB1/cA1-0.03#) * 0.5#
            FUNCTION = FORMAT$(cMatch,"#####.00")
            EXIT FUNCTION
        END IF
    
        cMatch = cA1 * 0.04# '3rd matching scenario
        FUNCTION = FORMAT$(cMatch,"#####.00")
    END FUNCTION
    For the most accurate results, should I change the numeric literals from DOUBLE to EXTENDED or CURRENCY, or is DOUBLE adequate?
Working...
X