formula

Java 1.5: mathematical formula parser

末鹿安然 提交于 2019-12-01 20:45:37
问题 Hello i often develop JTableModels in which some cells must contain the result of apliying a certain simple mathematical formula. This formulas can have: Operators (+,-,*,/) Number constants Other cell references (which contains numbers) Parameters (numbers with a reference name like "INTEREST_RATE") I often resolve it making a little calculator class which parses the formula, which syntax i define. The calculator class uses a stack for the calcs, and the syntax uses allways a Polish notation

Conditional group SUM in Crystal Reports

扶醉桌前 提交于 2019-12-01 19:55:48
I've been doing some accounting reports and have been summing up my different currencies using a formula IE CanadianCommissionFormula if {myData;1.CurrencyType} = "CDN" then {myData;1.Commission} else 0 CanadianCommissionSum SUM({@CanadianCommissionFormula}) Then I'd just display the CanadianCommissionSum at the bottom of the report and things were great. I've just come across the requirement to do this, but grouped by Sales Rep. I tried using my previous formula, but this sums for the whole report. Is there an easy way to sum like this, based on which group it's in? You probably figured this

Java 1.5: mathematical formula parser

自闭症网瘾萝莉.ら 提交于 2019-12-01 19:31:42
Hello i often develop JTableModels in which some cells must contain the result of apliying a certain simple mathematical formula. This formulas can have: Operators (+,-,*,/) Number constants Other cell references (which contains numbers) Parameters (numbers with a reference name like "INTEREST_RATE") I often resolve it making a little calculator class which parses the formula, which syntax i define. The calculator class uses a stack for the calcs, and the syntax uses allways a Polish notation. But the Polish notation is unnatural for me and for my users. So my question is... Is there a lib

How to determine luminance %?

a 夏天 提交于 2019-12-01 18:23:24
According to http://www.workwithcolor.com/color-luminance-2233.htm , RED (#FF0000) has Luminance: 54%. and light pink (#FF8080) has Luminance: 89%. Our designers like it but how is it determined? Try here: http://www.workwithcolor.com/hsl-color-schemer-01.htm I tried using relative luminance formula published by W3C and although the range is [0,1], red is 0.21 and white is 1.00 . I'm thinking, maybe what workwithcolor does is first covert the color into grayscale, and read the luminance of the gray. I tried it but it still doesn't give the same result. I've tried so far : http://jsfiddle.net

php calculate formula in string [duplicate]

帅比萌擦擦* 提交于 2019-12-01 13:55:27
This question already has an answer here: How to evaluate formula passed as string in PHP? 2 answers So I have formula as string $comm = "(a x 5% - 2%)"; I want it to be $comm = $a * 5/100 * (1-2/100); How can I do this in php? Stuart Wakefield To do this the right way, reliably and safely, from scratch, you will need to perform: Lexical analysis, this involves pattern matching the input with tokens: (a x 5% - 2%) would become something like the following chain of tokens: openparen variable multiply integer percent minus integer percent closeparen Syntax analysis, this involves taking those

Google Apps Script to VMerge tables WITH FORMATTING

[亡魂溺海] 提交于 2019-12-01 13:34:54
Does anyone know if there is a Google apps script out there that does what VMerge does but keeps the formatting of the tables being merged together? (in Google Spreadsheets) VMerge is a script that can be used as a custom formula but a script that I can trigger myself will do just fine too. Any help would be much appreciated. If you need a separate script to bring over the formatting... function myFunction() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var s = ss.getSheetByName('Sheet1'); s.getRange('A1').copyFormatToRange(sheet, column, columnEnd, row, rowEnd); } VMerge expects arrays-of

Excel Formula Optimisation

谁说我不能喝 提交于 2019-12-01 13:22:41
I am no excel expert and after some research have come up with this formula to look at two sets of the same data from different times. It then displays new entries that are in the latest list of data but not in the old list. This is my formula: {=IF(ROWS(L$4:L8)<=(SUMPRODUCT(--ISNA(MATCH($E$1:$E$2500,List1!$E$1:$E$2500,0)))), INDEX(E$1:E$2500, SMALL(IF(ISNA(MATCH($E$1:$E$2500&$F$1:$F$2500,List1!$E$1:$E$2500&List1!$F$1:$F$2500,0)), ROW($F$1:$F$2500)-ROW($F$1)+1),ROWS(L$4:L8))),"")} Are there any optimisation techniques I could employ to speed up the calculation? As requested Some example data

php calculate formula in string [duplicate]

微笑、不失礼 提交于 2019-12-01 13:20:00
问题 This question already has answers here : How to evaluate formula passed as string in PHP? (2 answers) Closed 6 years ago . So I have formula as string $comm = "(a x 5% - 2%)"; I want it to be $comm = $a * 5/100 * (1-2/100); How can I do this in php? 回答1: To do this the right way, reliably and safely, from scratch, you will need to perform: Lexical analysis, this involves pattern matching the input with tokens: (a x 5% - 2%) would become something like the following chain of tokens: openparen

Parsing a string formula to an integer result

ぃ、小莉子 提交于 2019-12-01 13:19:51
I'm doing some parsing work, too complex to get into details, but there's one simple thing I need to do (at least simple concept, maybe not simple answer). I might have a formula in a string such as the samples below. I need a function that will take a loosly-formatted formula string, parse it out, and calculate the result. Sample: (10 / 2)+(10/30) 5+(10/30) 5+3 8 Or: (12.5 - (0.5 * 5)) / 2 (12.5 - 2.5) / 2 10 / 2 5 Rules: Spaces are to be ignored PEMDAS method must entirely apply Result shall be always a rounded Integer No variables will exist, already converted to numbers Decimal numbers

Excel Formula Optimisation

孤街浪徒 提交于 2019-12-01 12:03:34
问题 I am no excel expert and after some research have come up with this formula to look at two sets of the same data from different times. It then displays new entries that are in the latest list of data but not in the old list. This is my formula: {=IF(ROWS(L$4:L8)<=(SUMPRODUCT(--ISNA(MATCH($E$1:$E$2500,List1!$E$1:$E$2500,0)))), INDEX(E$1:E$2500, SMALL(IF(ISNA(MATCH($E$1:$E$2500&$F$1:$F$2500,List1!$E$1:$E$2500&List1!$F$1:$F$2500,0)), ROW($F$1:$F$2500)-ROW($F$1)+1),ROWS(L$4:L8))),"")} Are there