Maths formula parser

Hi,
Does oracle provide any function that parses and evaluets a math formula/expression by resolving the operator precedence in it.
e.g. I have a math formula in the form of a string variable '(2+3)*(4+5)'
Does oracle have a function that will resolve this and return answer 45.
OR
Does anyone have a stored proc/func for this that I can use.
Any help is appreciated.
Thanks in advance.

I created this a long time ago in response to a post on this forum. Someone wanted an IIF() construct.
CREATE FUNCTION iif (p_expr IN VARCHAR2,
                     p_true_result IN VARCHAR2,
                     p_false_result IN VARCHAR2) RETURN VARCHAR2 IS
   l_sqlstr VARCHAR2(4000);
   l_result PLS_INTEGER;
BEGIN
   l_sqlstr := 'SELECT 1 FROM dual WHERE '||REPLACE(p_expr,'"','''');
   BEGIN
      EXECUTE IMMEDIATE l_sqlstr INTO l_result;
      RETURN p_true_result;
   EXCEPTION WHEN NO_DATA_FOUND THEN
      RETURN p_false_result;
   END;
END;{code}
or, for a strictky PL/SQL version (i.e. you can't call it in sql)
{code}CREATE FUNCTION iif (p_expr IN VARCHAR2) RETURN BOOLEAN IS
   l_sqlstr VARCHAR2(4000);
   l_result PLS_INTEGER;
BEGIN
   l_sqlstr := 'SELECT 1 FROM dual WHERE '||REPLACE(p_expr,'"','''');
   BEGIN
      EXECUTE IMMEDIATE l_sqlstr INTO l_result;
      RETURN TRUE;
   EXCEPTION WHEN NO_DATA_FOUND THEN
      RETURN FALSE;
   END;
END;The first version would be called like:
SELECT IIF('"A" in ("A","B","C") and 3 > 2 and 4 between 2 and 5','TRUE','FALSE') FROM dual;The second something like:
IF IIF('"A" in ("A","B","C") and 3 > 2 and 4 between 2 and 5') THEN
END IF;Just keep in mind Brian's comments about SQL injection from earlier in this thread
John

Similar Messages

  • XQuery syntax to evaluate math formula

    I want to evaluate a math formula inside of a function, so I can't use dynamic SQL.
    I found that the query on an XML-variable with a literal works well.
     DECLARE @sParsedFormula varchar(200);
     DECLARE @xFormula xml;
     SET @xFormula = '';
     SET @sParsedFormula = '1+2';
     SELECT @xFormula.query('3+3') , @xFormula.query('sql:variable("@sParsedFormula")')
    Output (1st value is correctly evaluated, 2nd not):
    "6", "1+2"
    I can't directly pass @sParsedFormula to the query otherwise I get "The argument 1 of the XML data type method "query" must be a string literal".
    What is the correct XQuery-syntax to evaluate the SQL:variable?
    Tx,
    Patrick

    You are obviously on the wrong track when you ask for the impossible.
    You can use sql:variable in XQuery to provide a value. You cannot provide an
    expression.
    If you want to pursue the set-up, your function will have to parse the expression and evalaute it. You can do this is in T-SQL, but it is not the best language for string parsing. Count on wast^H^H^H^Hspending quite a few hours on the development.
    If you do it in C#, undoubtedly it will be easier, and I would expect that you can find classes that performs the parsing and evaluation. This can reduce your development costs considerably.
    Of the languages I have worked with, there is one where the evaluting the expressions are dirt simple: Perl. Here you can just say
      $value = eval($expr)
    But running Perl code from SQL Server? Nah.
    If you want to do this in T-SQL only, it will have to be dynamic SQL. To avoid the cursor you can do somthing like:
       SELECT @sql =
         (SELECT 'SELECT ' + ltrim(str(id)) + ', ' + expr + ';' + char(13) + char(10)
          FROM   #temp
          FOR XML PATH(''), TYPE).value('.', 'nvarchar(MAX)')
      PRINT @sql
      INSERT #newtemp(id, value)
         EXEC (@sql)
      UPDATE #temp
      SET    value = n.value
      FROM   #temp t
      JOIN   #newtemp n ON t.id = n.id
    So, yes, XML had a place in your solution. But where you were looking.
    But note that with this solution, you will lose it all if one expression does not parse.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Using a Math Formula in AS3

    Hi,
    I am trying to test using a math formula (probit function) in AS3. I can't get the script to work: the dynamic text box is displaying NaN after I run the function and use a hard-coded number for the variable. Here's the button's script that is getting a NaN display. I must be doing something wrong and would appreciate any help getting it working.
    stop()
    var p:Number = 39 //hard-code this number for testing
    function NORMSINV(p:Number):Number {
        // Coefficients in rational approximations
        var a:Array = new Array(-3.969683028665376e+01,  2.209460984245205e+02,
                              -2.759285104469687e+02,  1.383577518672690e+02,
                              -3.066479806614716e+01,  2.506628277459239e+00);
        var b:Array = new Array(-5.447609879822406e+01,  1.615858368580409e+02,
                              -1.556989798598866e+02,  6.680131188771972e+01,
                              -1.328068155288572e+01 );
        var c:Array = new Array(-7.784894002430293e-03, -3.223964580411365e-01,
                              -2.400758277161838e+00, -2.549732539343734e+00,
                              4.374664141464968e+00,  2.938163982698783e+00);
        var d:Array = new Array (7.784695709041462e-03, 3.224671290700398e-01,
                               2.445134137142996e+00,  3.754408661907416e+00);
        // Define break-points.
        var plow:Number=0.02425;
        var phigh:Number=1-plow;
        // Rational approximation for lower region:
        if (p<plow) {
            var q:Number=Math.sqrt(-2*Math.log(p));
            return (((((c[0]*q+c[1])*q+c[2])*q+c[3])*q+c[4])*q+c[5]) /
                                                         ((((d[0]*q+d[1])*q+d[2])*q+d[3])*q+1);
        // Rational approximation for upper region:
        if (phigh<p) {
            q=Math.sqrt(-2*Math.log(1-p));
            return -(((((c[0]*q+c[1])*q+c[2])*q+c[3])*q+c[4])*q+c[5]) /
                                                                ((((d[0]*q+d[1])*q+d[2])*q+d[3])*q+1);
        // Rational approximation for central region:
        q=p-0.5;
        var r:Number=q*q;
        return (((((a[0]*r+a[1])*r+a[2])*r+a[3])*r+a[4])*r+a[5])*q /
                                     (((((b[0]*r+b[1])*r+b[2])*r+b[3])*r+b[4])*r+1);
    var n1:Number=NORMSINV(p)
    mathBtn.addEventListener(MouseEvent.CLICK, mathButtonClick, false, 0, true);
    function mathButtonClick(e:MouseEvent):void {
        T1.text = n1.toString()    //click the button and NaN displays
    Regards,
    saratogacoach

    I don't know the formula that you're trying to achieve, but the log and sqrt must use positive values.
    If you're uncertain if a variable (or formula result) will give you a negative result and you need a positive one, you can use the Math.abs, which return s always a positive value.
    I've just altered like this in the first IF:
    var q:Number=Math.sqrt(Math.abs(-2*Math.log(p)));
    and in the second:
    q=Math.sqrt(Math.abs(-2*Math.log(Math.abs(1-p))));
    In this case the second formula has two Math.abs since I don't know the result of "1-p" (in this case is negative) and then you multiply by "-2" wich will make the number negative again, so it has to be positive for the square root. If you have the change consider changing the formula to see you can eliminate, so many Math.abs, make it simple.
    Otherwise is just a question of predicting results and see if the formula fits right.

  • Math formulas and docs for IP forecasting strategies

    Hi all,
    For better understanding I neew math formulas for IP forecasting strategies.
    I've found some references on page http://help.sap.com/erp2005_ehp_04/helpdata/EN/44/03134ec148333de10000000a1553f7/content.htm to "For more information about forecasting in the context of demand planning, see http://help.sap.com/  ® Documentation ® mySAP Business Suite ® mySAP Supply Chain Management ® SAP Supply Chain Management ® SAP Advanced Planning and Optimization (SAP APO) ® Demand Planning ® Demand Planning Process ® Definition/Redefinition of Forecast Models ® Creating a Master Forecast Profile ® Univariate Forecasting."
    But I'didnt found that page. Any ideas?
    Thanks

    Hi,
    It could help...
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/1051f12c-66da-2b10-6dac-ec3acef8c4e8

  • How to use math formula on waveforms

    Hi all,
    I'm trying to create a program that can use math scipts, formulas etc on waveforms. I've done it for one signal, but I don't know how to change work on 2 or more signals;/ Let's see exampe: one channel is voltage, the second is current and I want to see both of them and as a third signal power so I'm writting formula ch3=ch1*ch2. Another example: I've signal which represents speed of starting motor (500 points) but I need only few points so the formula will be: ch1(20:120) and I have points from 20 to 120. Is it possible to do it? I can't do it using blocks cause I don't know which signal means what... so ch1 can be voltage, ch2 speed, ch3 current ch4-torqu etc. I know that I can cut a part of signal by subarray or subwaveform but it must be done by formula to use (for example) something like that:
    ch1(1:20)=0 <- replace all point from 1 to 20 of ch1 by 0
    ch2(50)=40 <-replace point 50 of ch2 by 40
    ch3=ch1*2 + ch2 <- do this operation but first do both above this one.
    Is it possible? or it's to complicated?
    I attached my vi which is working for one selected signal (I don't want to select it... but I don't know how to do it;/) and signal that I'm using to check how it's work
    Thanks
    Mike
    Attachments:
    Archive.zip ‏134 KB
    math formula.vi ‏152 KB

    I've upgraded it a little and it works with 2 signals but very sensible;/ formula must have this construction: c3= ... , both of signals must be switched on, there's no way to use part of signal (e.g.c1(21:54) ) and I can't use 2 rows (something like this: c3=c1*c2; c3=c1 doesn't work);/ additionally I wanted to have possibility to use all of signals as input and all of them as output
    Attachments:
    math formula.vi ‏183 KB

  • Does anyone know if there is a list of the functions/statements that can be used in the formula parsing (used in the VI Eval Formula String)? I

    have figured out a few already (ln(x), log(x), x^y, sin(x), asin(x), sinh(x), asinh(x), sqrt(x), pi(x), exp(x) ) but a complete list would be very useful. At the moment I am trying to figure out if it can handle factorials (x!). Any ideas? I am using LV6i.

    have figured out a few already (ln(x), log(x), x^y, sin(x), asin(x), sinh(x), asinh(x), sqrt(x), pi(x), exp(x) ) but a complete list would be very useful. At the moment I am trying to figure out if it can handle factorials (x!). Any ideas? I am using LV6i.Such a list is in Chapter 1 of the "G Math Toolkit Reference Manual". Please note that there are some differences to the formula node. Therefore, the help on the formula node lists some functions, that do not work with the Parser VIs.
    You can get the G Math manual from: www.ni.com/manuals
    Just search for "math".
    Hope this helps!
    Robert Buhrke, Systems Engineer
    Contact: [email protected]

  • Creating Complex Math Formulas in IDCS4 (Mac)

    I have to create a 180 page Engineering handbook for a company, with LOTS of complex mathematic formulas. It also has a lot of engineering drawings, sketches, tables, etc. I'll use IDCS4 on a Mac platform, OSX 10.6.7. I also have Acrobat Pro, PS and Illustrator from the CS4 Suite. Their final deliverable will be a PDF, which the customer will make available for download, so I definitely want to convert text, images drawings, etc, to the smallest possible size.
    Unfortunately, my customer has no electronic documents to work with. My current plan is to scan the original printed book, clean up the scans in Photoshop, then use OCR in Acrobat to convert characters to text. I will probably export to RTF, DOC, TXT or some other format so I can import into IDCS4 and create an electronic version (suggestions welcome).
    Unfortunately, Acrobat OCR butchers the formulas and turns them into goobledegook. What plugins or programs are people using to create fairly complex mathematical formulas inside IDCS4? Can I do it inside IDCS4, or do I need to work in Word, Pages, or a dedicated mathematical formula program? I will need Greek symbols, integrals, differential equation capability, etc.
    My main concern at this time is the formulas, but I am open to any suggestions on converting scanned images to vectors, handling tables, and the best way to get my text content into IDCS4 with the least amount of time and effort.
    Thanks for your help.
    Lou Dina

    Try these resources:
    http://www.unics.uni-hannover.de/nhtcapri/mathematics.html
    http://www.cs.tut.fi/~jkorpela/math/
    Alec Fehl, MCSE, A+, ACE, ACI
    Adobe Community Expert
    AUTHOR:
    Microsoft Office 2007 PowerPoint: Comprehensive Course
    (Labyrinth
    Publications)
    Welcome to Web Design and HTML (Labyrinth Publications)
    CO-AUTHOR:
    Microsoft Office 2007: Essentials (Labyrinth Publications)
    Computer Concepts and Vista (Labyrinth Publications)
    Mike Meyers' A+ Guide to Managing and Troubleshooting PCs
    (McGraw-Hill)
    Internet Systems and Applications (EMC Paradigm)

  • Creating Math Formulas in Dreamweaver

    I've been given an assignment to create a web page for an
    online precalculus mathematics course using Dreamweaver. I know
    just enough about web site design to get by creating very basic
    sites, so this is quite a challenge for me! The course materials
    are currently in MS Word format and a lot of the formulas appear to
    have been created with the formula editor. I tried copying the
    formulas from the Word doc and pasting them into Dreamweaver, but
    they look distorted (and I have a feeling this isn't a great idea).
    Does anyone out there have experience creating mathematical
    formulas in Dreamweaver--or importing them from another program?
    There are literally hundreds of formulas and diagrams throughout
    the course, so I'm looking for an efficient way of doing
    this.

    Try these resources:
    http://www.unics.uni-hannover.de/nhtcapri/mathematics.html
    http://www.cs.tut.fi/~jkorpela/math/
    Alec Fehl, MCSE, A+, ACE, ACI
    Adobe Community Expert
    AUTHOR:
    Microsoft Office 2007 PowerPoint: Comprehensive Course
    (Labyrinth
    Publications)
    Welcome to Web Design and HTML (Labyrinth Publications)
    CO-AUTHOR:
    Microsoft Office 2007: Essentials (Labyrinth Publications)
    Computer Concepts and Vista (Labyrinth Publications)
    Mike Meyers' A+ Guide to Managing and Troubleshooting PCs
    (McGraw-Hill)
    Internet Systems and Applications (EMC Paradigm)

  • Formula parser

    java gurus,
    i am searching for a parser which should evaluate formulas. so if i have something in a string like "4/4+4/4" it should return 2.
    any ideas where to find that?
    thanx a lot and please also reply to my email [email protected]
    regards,
    richard

    Try ANTLR at http://www.antlr.org
    but then for simple formulas this might be overkill.

  • Convert data values in columns to another value based on a math formula

    ISSUE:
    I have a database of emergency incidents with descriptive data and longitude and
    latitude. I would like to make a google map out of the information but unfortunately
    the X Y coordinates are projected in Florida State Plane West in feet. Google maps
    requires WGS84 longitude and latitude in decimal degrees.
    PROBLEM:
    I have written some code in Transact SQL that will convert the values. But I am at a loss as to how to do the following:
    1.) plug in the X Y values from my database using an sql SELECT statement.
    2.) apply the formula to convert from State Plane to WGS84 to these X Y values
    3.) output the results.
    In other words, I have the data and I have the formula, but I am not figuring out how to plug the data into the formula and output the results. I am missing how to tie it all together.
    CODE:
    DECLARE @Easting DECIMAL(18,10);
    --SET @Easting = CAST(I_MapX AS DECIMAL(18,10));
    DECLARE @Northing DECIMAL(18,10);
    --SET @Northing = CAST(I_MapY AS DECIMAL(18,10));
    DECLARE @m2sft DECIMAL(10,10);
    SET @m2sft = 1200.0/3937.0;
    DECLARE @N0 DECIMAL(3,2);
    SET @N0 = 0.0;
    DECLARE @E0 DECIMAL(18,11);
    SET @E0 = 656166.6666666665;
    DECLARE @S0 DECIMAL(12,5);
    SET @S0 = 2692050.5001/@m2sft;
    DECLARE @K0 DECIMAL(18,18);
    SET @K0 = 0.9999411764705882;
    DECLARE @a DECIMAL(10,2);
    SET @a = 6378137.0/@m2sft;
    DECLARE @e DECIMAL(18,17);
    SET @e = 0.0818191911198883;
    DECLARE @ePrime DECIMAL(18,17);
    SET @ePrime = 0.08208852110265381;
    DECLARE @r DECIMAL(18,10);
    SET @r = 6367449.14577/@m2sft;
    DECLARE @V0 DECIMAL(15,12);
    SET @V0 = 0.005022893948;
    DECLARE @V2 DECIMAL(15,12);
    SET @V2 = 0.000029370625;
    DECLARE @V4 DECIMAL(15,12);
    SET @V4 = 0.000000235059;
    DECLARE @V6 DECIMAL(15,12);
    SET @V6 = 0.000000002181;
    DECLARE @L0 DECIMAL(4,2);
    SET @L0 = 82.0;
    DECLARE @w DECIMAL(18,10);
    SET @w = (@Northing - @N0 + @S0)/(@k0*@r);
    DECLARE @of DECIMAL(18,10);
    SET @of = @w + (sin(@w)*cos(@w))*(@V0 + @V2*power(cos(@w),2) + @V4*power(cos(@w),4) + @V6*power(cos(@w),6));
    DECLARE @Rf DECIMAL(18,10);
    SET @Rf = @k0*@a/sqrt((1 - power(@e,2)*power(sin(@of),2)));
    DECLARE @EPrime2 DECIMAL(18,10);
    SET @EPrime2 = @Easting - @E0;
    DECLARE @Q DECIMAL(18,10);
    SET @Q = @EPrime2/@Rf;
    DECLARE @tf DECIMAL(18,10);
    SET @tf = tan(@of);
    DECLARE @nf DECIMAL(18,10);
    SET @nf = @ePrime*cos(@of);
    DECLARE @B2 DECIMAL(18,10);
    SET @B2 = -0.5 * @tf * (1 + POWER(@nf,2));
    DECLARE @B4 DECIMAL(18,10);
    SET @B4 = -1/12*(5 + 3 * POWER(@tf,2) +POWER(@nf,2) * (1-9 * POWER(@tf,2)) - 4 * POWER(@nf,4));
    DECLARE @B6 DECIMAL(18,10);
    SET @B6 = 1/360*(61 + 90*POWER(@tf,2) + 45*POWER(@tf,4) + POWER(@nf,2)*(46 - 252*POWER(@tf,2) - 90*POWER(@tf,4)));
    DECLARE @Latitude DECIMAL(18,10);
    SET @Latitude = (@of + @B2*POWER(@Q,2)*(1 + POWER(@Q,2)*(@B4 + @B6*POWER(@Q,2))))*180/(PI());
    DECLARE @B3 DECIMAL(18,10);
    SET @B3 = -1/6*(1 + 2*POWER(@tf,2) + POWER(@nf,2));
    DECLARE @B5 DECIMAL(18,10);
    SET @B5 = 1/120*(5 + 28*POWER(@tf,2) + 24*POWER(@tf,4) + POWER(@nf,2)*(6 + 8*POWER(@tf,2)));
    DECLARE @B7 DECIMAL(18,10);
    SET @B7 = -1/5040*(61 + 662*POWER(@tf,2) + 1320*POWER(@tf,4) + 720*POWER(@tf,6));
    DECLARE @L DECIMAL(18,10);
    SET @L = @Q*(1 + POWER(@Q,2)*(@B3 + POWER(@Q,2)*(@B5 + @B7*POWER(@Q,2))));
    DECLARE @Longitude DECIMAL(18,10);
    SET @Longitude = (@L0 - (@L/cos(@of))*180/(PI()))*-1;
    SELECT
    I_EventNumber
    FROM Incident
    WHERE I_tTimeDispatch > 'May 7, 2012'
    SAMPLE DATA:
    Here is some raw data in order to get you started. Please notice the MapX and MapY
    coordinates are VARCHAR because they are Florida State Plane projections. The goal is
    to take these and turn them into WGS84 longitude and latitude expressed as decimal
    degrees to be used in Google maps. NOTE: I can convert from VARCHAR to DECIMAL. I just can't figure out where to plug my database columns into the sql query to output a result.
    CREATE TABLE Incidents
    I_EventNumber VARCHAR(20)
    I_MapY VARCHAR(15)
    I_MapX VARCHAR(15)
    INSERT INTO Incident
    VALUES
    (FCW69, 0815312, 0672298)
    , (FCW70, 0833311, 0697870)
    , (FCW71, 0807747, 0699684)
    , (FCW72, 0801252, 0689469)
    , (FCW73, 0853491, 0692350)

    Here's a way to get the results, all as part of a single extensive query (this would probably be more suited for defining a VIEW, where you could join on the input table with the VIEW to incorporate the computed values.
    If you instead had a business situation where you might need to execute this logic from many different places, rewriting as a user defined function might be better.  Anyway, for the answer plus a demonstration of the power of CROSS APPLY to generate
    interim working values...
    Create_Sample_Data:
    Declare @Incident TABLE
    I_EventNumber VARCHAR(20), I_MapY VARCHAR(15), I_MapX VARCHAR(15)
    INSERT INTO @Incident
    VALUES
    ('FCW69', '0815312', '0672298')
    , ('FCW70', '0833311', '0697870')
    , ('FCW71', '0807747', '0699684')
    , ('FCW72', '0801252', '0689469')
    , ('FCW73', '0853491', '0692350') /* This insert is SQL 2008 syntax only.. do multiple inserts or a UNION for 2005 */
    AsQuery:
    Select *
    from @INCIDENT
    Cross Apply
    Select
    N0 = 0.0,
    E0 = 656166.6666666665,
    K0 = 0.9999411764705882,
    e = 0.0818191911198883,
    ePrime = 0.08208852110265381,
    V0 = 0.005022893948,
    V2 = 0.000029370625,
    V4 = 0.000000235059,
    V6 = 0.000000002181,
    L0 = 82.0,
    Easting = CAST(I_MapX AS DECIMAL(18,10)),
    Northing = CAST(I_MapY AS DECIMAL(18,10))
    ) as CAStatic
    Cross Apply
    Select m2sft = 1200.0/3937.0,
    EPrime2 = Easting - E0
    ) as CAComputed1
    Cross Apply
    Select S0 = 2692050.5001/m2sft,
    r = 6367449.14577/m2sft,
    a = 6378137.0/m2sft
    ) as CAComputed2
    Cross Apply
    Select
    w = (Northing - N0 + S0)/(k0*r)
    ) as CAComputed4
    Cross Apply
    Select
    [of] = w + (sin(w)*cos(w))*(V0 + V2*power(cos(w),2) + V4*power(cos(w),4) + V6*power(cos(w),6))
    ) as CAComputed5
    Cross Apply
    Select
    Rf = k0*a/sqrt((1 - power(e,2)*power(sin([of]),2))),
    tf = tan([of]),
    nf = ePrime*cos([of])
    ) as CAComputed6
    Cross Apply
    Select
    Q = EPrime2/Rf,
    B2 = -0.5 * tf * (1 + POWER(nf,2)),
    B4 = -1/12*(5 + 3 * POWER(tf,2) +POWER(nf,2) * (1-9 * POWER(tf,2)) - 4 * POWER(nf,4)),
    B6 = 1/360*(61 + 90*POWER(tf,2) + 45*POWER(tf,4) + POWER(nf,2)*(46 - 252*POWER(tf,2) - 90*POWER(tf,4)))
    ) as CAComputed7
    Cross Apply
    Select
    Latitude = ([of] + B2*POWER(Q,2)*(1 + POWER(Q,2)*(B4 + B6*POWER(Q,2))))*180/(PI()),
    B3 = -1/6*(1 + 2*POWER(tf,2) + POWER(nf,2)),
    B5 = 1/120*(5 + 28*POWER(tf,2) + 24*POWER(tf,4) + POWER(nf,2)*(6 + 8*POWER(tf,2))),
    B7 = -1/5040*(61 + 662*POWER(tf,2) + 1320*POWER(tf,4) + 720*POWER(tf,6))
    ) as CAComputed8
    Cross Apply
    Select
    L = Q*(1 + POWER(Q,2)*(B3 + POWER(Q,2)*(B5 + B7*POWER(Q,2))))
    ) as CAComputed9
    Cross Apply
    Select
    Longitude = (L0 - (L/cos([of]))*180/(PI()))*-1
    ) as CAComputedLatLong
    Notice that each subsequent CROSS APPLY depends on a "working value" column being defined in some previous cross apply, or the working query.  There are a few other options, such as leaving off the very last Cross Apply, and computing Longitude as part
    of the main query at the beginning, but it works either way.
    EDIT: P.S. - By the way, this query is based on the formula in the original poster's query.  My formula matches that formula, and I bet it's right (as far as the lat/long conversion), but it could be the formula for Soylent Green, and I wouldn't know any
    better... :-)

  • XML value being turned into math formula.

    I am not using E4X, but here is the scenario:
    Okay, so I am bringing in a string with a value of 33E-30 for
    Train Id. Java is returning the following XML to my flex component:
    <train>
    <trainId>33E-30</trainId>
    <cars>60</cars>
    <length>3751</length>
    <weight>2712</weight>
    <callTime>null</callTime>
    <comments>null</comments>
    <eta>2007-10-30 05:00:00.0</eta>
    <fromRoad>NS</fromRoad>
    <toRoad>UP</toRoad>
    <interchange>Elkhart (testing)</interchange>
    <locationName>Elkhart (testing)</locationName>
    <trainType>R5</trainType>
    <latitude>41</latitude>
    <longitude>-86</longitude>
    <splc>362120</splc>
    </train>
    I then take the value and put it in a Value Object typed as a
    String. Flex then displays the following:
    3.2999999999999997e-29
    It looks like Flex is treating this as some mathematical
    formula instead of as a string, even though it is typed as a
    string. Any ideas on how to work around this? I am thinking that it
    is happening when the xml is being read into the object.

    I did some more research and the it looks like Flex is making
    the change in the ResultEvent processing, or it is showing up as
    3.299999... in the source attribute of the response object. Rather
    odd.
    Is there a way to turn of this attempt at scientific
    notation?

  • Basic math formula problems, percentage formatting

    Hi!
    I have a table full of data, and I'd like to calculate the percentage change from one row to the next.
    I thought I could use formula like
    =(J3-J2)/J2
    And this works. I get result like 0.31.
    I'd like to format it as percentage. Clicking on the "Format as percentage button" changes my formula and makes it invalid.
    The cell value becomes:
    =(Total 1.6.2009-Total 1.5.2009)/Total 1.5.2009
    "Total" is the name of the column (which is actually a sum of items on the row) and "1.5.2009" is the name of the row.
    Why does Numbers destroy the formula to use the names of the row and column instead of cell reference?
    By the way, I can't just add " * 100" to my formula to have it be 31 instead of 0.31, that will also cause a formula syntax error.
    So I'm trying to calculate percentage change from one sum cell to the sum cell on the next row, but this doesn't seem possible.
    Any ideas?

    Petteri,
    I suppose there is a possibility that when you first attempted to apply Percent format to your result you made some wrong key-press.  It should work correctly that way, and does on my system.
    One tip; If I were you, I would turn off that "Use Header Cell Names as References" Preference.  It's more trouble than it is worth.  Just a gimmick in my opinion.
    Jerry

  • How to implement mathematical formula parsing

    how can i implement mathematical expression parsing...
    A expression like (a*b)-((sin(-2a)))
    1.A=-2*a
    2.sinA
    3.B=a*b
    4.C=B-A
    The answer is C
    like that i need for any given expression...
    Thanks..

    Rams_India --
    The original posted question was how can i implement mathematical expression parsing..and not if such type of parsing is possible in j2me or not.
    With such an attitude, you're sure to scare away people that may be of help to you.
    You really need to read [code of conduct|http://wikis.sun.com/display/SunForums/Sun+Forums+Code+of+Conduct] of this forum.

  • How to get a formula from the user from a text box in a webpage

    Hi. I would like to know how to get the formula from the user who enters in a textbox. This formula can have any number of variables starting with a and goes on.
    The complexity of the formula can go upto sin, cos, ln, exp. Also user enters the minimum and maximum values of these variables. Based on a specific algorithm (which I use) I would calculate a *set of values, say 10, for each of these variables, substitute in the formula and based on the result of this formula, I select ONE suitable  value for each of the variables.
    I don't know how to get this formula (which most likely to be different each time) and substitute the values *which I found earlier.
    Kindly help me out in this issue.
    Thanks

    The textbox is the easy part. It's no different than getting a String parameter out of an HTTP request.
    The hard part is parsing the String into a "formula" for evaluation. You'll have to write a parser or find one.
    Google for "Java math expression parser" and see what you get.
    Or write your own with JavaCC.
    %

  • Is Edge a good tool to build math/science simulations

    We are building math and science simulations for dept of Edu and wonder if Edge will be a good tool for us or not. Our simulations include creating graphs from math formulas, or draw a sine wave by following a fixed point on a rotating circle, or depict a law of action-reaction in physics. And most of our simulation require pixel drawing. In Flash it's easy to draw the and create any object path. but don't know how to do that with Edge.
    Thanks
    D.

    Hi, folks-
    Right now, there is no way to do custom motion path animation natively in Edge Animate.  As resdesign mentioned, you can use Canvas as an external tag, though there are certainly things you can do with linear motion as a part of educational material.
    Hope this helps,
    -Elaine

Maybe you are looking for