calculation

ActiveRecord::EagerLoadPolymorphicError: Can not eagerly load the polymorphic association

class Transaction < ActiveRecord::Base belongs_to :account, :polymorphic => true end class Bankaccount < ActiveRecord::Base has_many :transactions, :as => :account end class Creditcard < ActiveRecord::Base has_many :transactions, :as => :account end Trying to do a summation of transactions where the account is active. Transacti...

java based calculation engine based on Open Ofice Calc

Hi The requirement is to build a calculation engine which is performant and supports excel like formulas. These formulas need to be applied on huge data sets (millions of rows of data). I was thinking if something could be built on top of OpenOffice Calc service and make it available as a Calculation Engine. Does anyone have any expe...

jquery datepicker, dates range count

Hello, i am trying to sum up or deduct dates in selected range using jquery datepicker, here is how i am doing it right now but without any luck. function test(){ var sundayCheck = 0; var saturdayCheck = 0; var totalDays = 0; sundayCheck = new Date($("#onlySunday").datepicker("getDate")); saturdayCheck = new Date(...

Iphone Animation - Calculation to plot Cartesian Coordinates

I have two points (x1, y1) A & (x2, y2) B. I want to animate an image from point A to point B but also have a touch event on that image. What is the best way to accomplish this? I am currently using CGPointMake to manually plot points but I want to be able to just plug in the two coordinates and have a timer loop to move the object. I...

What is the best algorithm to calculate the most scored item?

I have an music items that are scored by users between 1 to 5, and I need a formula to get the 5 most scored items. But obviously an item that get 3.5 average score from 1000 different users will be more scored then an item thet get 4.9 average score from only 5 users... in other words I think that if an item get attention from people ...

Calculate scrollbar height according to amount of hidden contents

I'm creating a graphical scrollbar so I need to calculate the scrollbar height manually. You know how in most applications the scrollbar height changes based on how much there is to scroll? What is the formula for calculating the scrollbar height based on the amount of hidden contents? Is it logarithimic or exponential or just plainly b...

Simple way to convert 00:20:40.28 (hours:minutes:seconds.split seconds) to seconds

Whats an easy way to convert 00:20:40.28 to seconds with a bash script? (Split seconds can be cut out, it’s not essential.) ...

Do the math sum of a text variable? (E.g 5865/100 )

I have a variable that is... $whatever = "5865/100"; This is a text variable. I want it to calculate 5865/100 , so that I can add it to other numbers and do a calculation. Number_format doesn't work, as it just returns "5,865". Whereas I want it to return 58.65 I could do... $explode=explode("/",$whatever); if(count($explode)=="2")...

Reordering list of jQuery objects to columns

Hello, I'm working on function, that takes a select from html and replaces it with multi-column ul - it's one list, but has float:left; on li children, so the number of columns is based on calculations (if ul width is 600 and li width is 200, i will obviously have 3 columns). That's theory - the easy part. Example: 5 items, 2 columns ...

How to find control points for a BezierSegment given Start, End, and 2 Intersection Pts in C# - AKA Cubic Bezier 4-point Interpolation

Hi, I've been struggling looking for an understandable way to do this. I have four points, a StartPt, EndPoint, and Intersection points to represent the peak and valley in the bezier. The BezierSegment in C# requires start, controlPoint 1, controlPoint 2, endpoint - however I don't have any control points I only have these two points t...

Calculate how much bigger one image is from the other one.

Some math calculations in JS problem solving I am working on a zoom image functionality that creates a new div with a large image that is moved through x and y according to the mousemove on the image. The large image should move a certain %, which is what i am trying to figure out. How much should it move by. Here is some info: T...

Python:Which way gives better precision

Is there any difference in precision between one time assignment: res=n/k and multiple assignment in for cycle: for i in range(n): res+=1/k ? ...

age calculation in Flex

I'm trying to calculate age in flex. I've found this previous question http://stackoverflow.com/questions/41763/what-is-the-best-way-to-calculate-age-using-flex I'm sort of leaning towards this private function calculateAge(dob:Date):String { var now:Date = new Date(); var ageDays:int = 0; var ageYears:int = 0; var ageRmdr:in...

Calculation Conundrum - how do I influence another textfield?

Hey! Basically I have a problem in that when certain parameters are used in my calculator app - it makes the result incorrect. The issue is that I have separate text fields for hours and minutes and say for example I have as the start time "13" in one text field and "30" in the other with the finish time "24" and "00" in their respectiv...

Calculate the sum of DIV content

Hi all, I have a form with several SELECT boxes and based on the user's selection a value appears. This is fully working. Now I want a script that calculates the SUM of these values either automatically or when pressing a button. The full code I have so far is this: The JavaScript: <script type="text/javascript"> window.onload=funct...

Calculation Expression Parser with Nesting and Variables in ActionScript

Hi There, I'm trying to enable dynamic fields in the configuration file for my mapping app, but I can't figure out how to parse the "equation" passed in by the user, at least not without writing a whole parser from scratch! I'm sure there is some easier way to do this, and so I'm asking for ideas! Basic idea: public var testString:Stri...

Calculating Average Percentage Yield (APY) with T-SQL

How do you calculate Average Percentage Yield (APY) with T-SQL? Is there a system function to calculate APY or do I have to create one? Note: APY = (1 + r/n )^n – 1 where r is the stated annual interest rate and n is the number of times you’ll compound per year. ...

how to calculate a bill from several tables on mysql?

I'm using mysql to create an hotel booking system, but i am struggling a little bit to calculate the final bill. I need a SELECT command to get data from several tables and make some calculations. Basically I just need to get the 'night cost' from a table called 'room_types'. Then, use DATEDIFF function to get the difference of days be...

Calculation error in Datasheet view in SharePoint

I have a custom list, with calculation, in SharePoint. Everything worked fine until recently when the DataSheet will show strange or wrong % calculation in a % column. But the Standard View will show correct values. IT checked the server side and everything looked ok, I checked the formulas and even re-did them in the column and the issu...

Is there a way to get access to the row height previously calculated in "heightForRowAtIndexPath" ?

Hey everyone, I calculate the height of a row in the method "heightForRowAtIndexPath" but I need to use this value in the method "cellForRowAtIndexPath" ... is there a way to get access to the value already calculated or do I need to do the calculations again ? Thks, Gotye. ...