calculation

php convert floating point to long (convert to string to pass to a xml function)

Hi, PHP converts a large number to floating point which I need in "long" format to pass to a soap xml api. ((round(time()/(60*15))*60*15)+(30*60))*1000 This gives the result: 1.28E+12 Whereas, what I need is: "1280495700000" in order to pass to the api ...

optimization, branching elimination

float mixValue = ... //in range -1.0f to 1.0f for(... ; ... ; ... ) //long loop { float inputLevel = ... //in range -1.0f to 1.0f if(inputLevel < 0.0 && mixValue < 0.0) { mixValue = (mixValue + inputLevel) + (mixValue*inputLevel); } else { mixValue = (mixValue + inputLevel) - (mixValue*inputLevel)...

get all markers within a given radius in sql

I'm trying to get all locations stored in the database with an sql statement described here My sql statement is: SELECT TOP(10) *, ( 6371 * acos( cos( radians(<cfqueryparam cfsqltype="CF_SQL_Numeric" value="#FORM....

Algorithm for calculating result of multi-choice quiz

I'm struggling with the edge cases of an algorithm for calculating the result of an A, B, C style quiz. The quiz is made up of an arbitrary number of questions, each having exactly 3 answers corresponding to A, B and C. Each question is displayed on its own with a continue button, once all questions have been answered the result is disp...

jQuery addition of multiple text box values

Hi all, I have a new task to do and im not sure the best way to approach it with jQuery. Basically a client wants 'x' amount of text boxes (for quantity) each with a plus/minus button/icon to the side of it and as you click on each one, all the relative fields update. e.g. (if there were 3 options in a page) qty [ 0 ] + - qty [ 0 ] +...

jQuery adding multiple text boxes

Hi all, I wonder if anyone could help me. I have a web page where there are some text boxes (dynamic amount, could be 3, could be 30) and each one a user can enter a number and I have a total count at the bottom. At present I have this: $('input.qty').change(function() { // Get the current total value var total = $('#total'); // Upda...

What programme to use for large database (numbers) later to use for calculation, analysis and graphic?

Currently, I am working on a folder of Excel which consist of database (number) size of 1.34GB 63 files and growing. I can continue to work in Excel but I have to separate one large piece of file into several sub-files which is not very convenience and sometimes confusing when it come to calculation, analysis and graphic. I wonder if th...

How to check collision in a drawn curve, instead of the Sprite's bound box

There are two Sprite's hit tests, one check the object (and have no precision on the curves) and the other check a specified (x, y) point. But, having curves drawn using Graphics.curveTo(), how do I check if 2 drawn curves are colliding? I'm not sure if this is an actionscript or a math problem... I want to check all (x,y) of a curve to...

Practical uses of trig functions

What are some practical applications of sine, cosine, arc sine, etc. Can you distort images, calculate special values, or other stuff? Any opinions of the most used/important? ...

Distance calculation between two zip codes(post codes) in php?

I am working on a website which requires distance calculation between two zip-codes. I have a database table which consists of zip-codes and their related latitudes and longitudes. I make use of this to calculate distance between the two places. But I have a problem that this gives me straight line distance and not driving distance - h...

How would I calculate EXPECTED income if I have PAST income data in mySQL?

Ok, I'm just curious what the formula would be for calculating an expected income over the next X weeks/months/etc, if the only data I have in mySQL DB is all past transactions (dates of transactions, amounts, etc) I am thinking taking some averages and whatnot, but I can't think of a specific formula (there must be something along thos...

semantic mediawiki property calculation

Hi, I installed the MediaWiki-extension Semantic MediaWiki recently. In this extension you can define properties. They are like categories for values. If I define two properties like this: [[StartYear::2000]] [[EndYear::2005]] Is it possible to make calculations based on these properties if I do a semantic search. For example: {{#a...

Strange problem with the vector when calculating values to a member.

This is an updated follow-up from my last question: http://stackoverflow.com/questions/3494178/fatal-error-from-incrementing-loop I've finished the sorting algorithm, which seems to work fine. Now my problem is trying to calculate the health for each fighter(in the getHealth() function) based on levels in my vector to calculate correctly...

Calculating Ages in R

Hello everyone. I have two data frames in R. One frame has a persons year of birth: YEAR /1931 /1924 and then another column shows a more recent time. RECENT 09/08/2005 11/08/2005 What I want to do is subtract the years so that I can calculate their age in number of years, however I am not sure how to approach this. Any help please...

1/252 = 0 in c#?

I'm doing a calc and while debugging i found this: double num = 1/252; when I debugged this, num is set to zero (0). Is there a reason for this? I'd like to make it the actual calculation. Thanks ...

calculation between two rows of DataTable in C#

Hi. I have Datatable which has tow tables together appended. I have many rows in that two of which are Total and Rate.( Note this are the Rows in my Datatable). I want to calulalte the total amount by multiplying the two rows. How shall I do that. The datatables are coming from sql Compact and I cannot do their the calculation as it's no...

sql query constructing formula

i have a table with two column: Name Values ---------------- Target 20 v1 10 v2 20 v3 10 Total 30 percent ? i want to calculate the percentage with the single column value to get the formula as --> Target/Total * 100. i.e for ex: Total = SUM (Values) in that way...... by using two rows in the colu...

using a column's value in calculation in mysql query

I have this code which should (hopefully) get the closest results to a given location: $sql = "SELECT *, lat as LAT, long as LONG FROM mellow_listings ORDER BY SQRT(((".$long."-LONG)*(".$long."-LONG)) +((".$lat."-LAT)*(".$lat."-LAT))) ASC LIMIT 0,10"; for some reason it isn't working at all. I think its because I'm incorre...

MySQL or PHP date averages

Hey, I am trying to figure out how to find the average of a number of different time values, the time values are time differences from 2 dates so they will be in the format of "hh:mm:ss". So if I had 4 time values of: 00:11:05 00:01:30 00:04:25 00:09:50 I am having trouble figuring this out. I am thinking that these time values woul...

Calculating points from 0-10 for achived time

I have a Google Spreadsheet with a value (in seconds) for a lot of teams. I want to calculate points for each team from 0-10: 10 points for the team with the lowest value, 0 points for the team with the highest value and 9-1 points for the values in between (evenly distributed). I honestly can't think of any formular to do this...and I ...