math

What's the difference between Math.Floor() and Math.Truncate() in .NET?

What is the difference between Math.Floor() and Math.Truncate() in C#? ...

Solving a linear equation

I need to programmatically solve a system of linear equations in C, Objective C, or (if needed) C++. Here's an example of the equations: -44.3940 = a * 50.0 + b * 37.0 + tx-45.3049 = a * 43.0 + b * 39.0 + tx-44.9594 = a * 52.0 + b * 41.0 + tx From this, I'd like to get the best approximation for a, b, and tx....

A little diversion into floating point (im)precision, part 1

Most mathematicians agree that e ** (πi) + 1 = 0. However, most floating point implementations disagree. How well can we settle this dispute? I'm keen to hear about different languages and implementations, and various methods to make the result as close to zero as possible. Be creative! ...

Mapping latitude/longitude to a distorted map

I have a bunch of latitude/longitude pairs that map to known x/y coordinates on a (geographically distorted) map. Then I have one more latitude/longitude pair. I want to plot it on the map as best is possible. How do I go about doing this? At first I decided to create a system of linear equations for the three nearest lat/long points a...

What does the term "BODMAS" mean?

What is BODMAS and why is it useful in programming?...

Puzzle: Find largest rectangle (maximal rectangle problem)

What's the most efficient algorithm to find the rectangle with the largest area which will fit in the empty space? Let's say the screen looks like this ('#' represents filled area): .................... ..............###### ##.................. .................### .................### #####............... #####............... #####......

Useful math for programmers

In your experience as a practicioner, what's the most useful math knowledge for a programmer? If "it depends", what's your field of expertise and what do you need there most as far as math is concerned? Can you point to any learning material for a beginner? ...

Do you have to be good at math to be a good programmer?

It seems that conventional wisdom suggests that good programmers are also good at math. Or that the two are somehow intrinsically linked. Many programming books I have read provide many examples that are solutions to math problems, or are somehow related to math as if these examples are what make sense to most people. So the question I ...

How to Round Up The Result Of Integer Division

I'm thinking in particular of how to display pagination controls, when using a language such as C# or Java. If I have x items which I want to display in chunks of y per page, how many pages will be needed? ...

Where can I find a "Math topic dependency tree" to assist my self-guided refresher on the subject?

I'm trying to reteach myself some long forgotten math skills. This is part of a much larger project to effectively "teach myself software development" from the ground up (the details are here if you're interested in helping out). My biggest stumbling block so far has been math - how can I learn about algorithms and asymptotic notation...

Prime factors

What is the best approach to calculating the largest prime factor of a number? I'm thinking the most efficient would be the following: Find lowest prime number that divides cleanly Check if result of division is prime If not, find next lowest Go to 2. I'm basing this assumption on it being easier to calculate the small prime factors...

Calculating Distance Between 2 Cities

How do you calculate the distance between 2 cities? ...

The Google Calculator Glitch, could float vs. double be a possible reason?

I did this Just for kicks (so, not exactly a question, i can see the downmodding happening already) but, in lieu of Google's newfound inability to do math correctly (check it! according to google 500,000,000,000,002 - 500,000,000,000,001 = 0), i figured i'd try the following in C to run a little theory. int main() { char* a = "399999...

How do I calculate distance between two latitude longitude points?

Here's an easy one for you: How do I calculate the distance between two points points specified by latitude and longitude? EDIT: For clarification, I'd like the distance in kilometres, the points use the WGS84 system and I'd like to understand the relative accuracies of the approaches available. ...

Popularity algorithm

On SO 18 Joel mentioned an algorithm that would rank items based on their age and popularity and it's based on gravity. Could someone post this? C# would be lovely, but really any language (well, I can't do LISP) would be fine. ...

Russell's Paradox

Let X be the set of all sets that do not contain themselves. Is X a member of X? ...

Calculate Video Duration

I suck at math. I need to figure out how to calculate a video duration with only a few examples of values. For example, a value of 70966 is displayed as 1:10 minutes. A value of 30533 displays as 30 seconds. A value of 7007 displays as 7 seconds. ...

How do I calculate a trendline for a graph?

Google is not being my friend - it's been a long time since my stats class in college...I need to calculate the start and end points for a trendline on a graph - is there an easy way to do this? (working in C# but whatever language works for you) ...

Modulus operation with negatives values - weird thing ??

Can you please tell me how much is (-2) % 5 ? According to my python interpreter is 3, but do you have a wise explanation for this ? I've read that in some languages the result can be machine-dependent, but I'm not sure though. Thanks for your help. ...

Can you be terrible at math and still a great programmer?

I'm just after reading Jeff's 'Five Things You Didn't Know About Me (and my office)' blog entry on Coding Horror and right at the bottom of this page he mentions (to my surprise) that he is terrible at math: http://www.codinghorror.com/blog/archives/000770.html He's obviously not that bad as I do reckon that a certain level of math is ...