I have found that the same mod operation produces different results depending on what language is being used.
In Python:
-1 % 10
produces 9
In C it produces -1 !
1) Which one is the right modulo?
2) How to make mod operation in C to be the same like in Python?
Thank you in advance!
...
I have a weird problem in asp.NET when calculating how many hours we need to invoice.
In the below example, we have a total of 75,9 hours that need to be invoiced.
These hours are spread over several database rows (TimeIDs).
Basically, I always deduct the "amount_invoiced" from the "to invoice" hourly count:
TimeID:25433 - to invoice...
I am adding "layer" objects to the stage with a depth value.
I have then created my own camera class. When I tell the camera to move to the right what Im actually doing is telling each layer object to move to the left.
The distance that the layer moved to the left is based on the value of its depth variable...
var fCameraDepth = 1;
va...
Is it standard across all languages for the following to yield the value 3?
Print(6 - 2 - 1)
In other words, are there any languages that will evaluate " 2 - 1 " before " 6 - 2 "?
I'd like to make this assumption so that I can quit instinctively inserting parentheses ((6 - 2) - 1). It leave me at risk of LISP nightmares.
Thanks
...
Hi,
I needed an application for solving linear systems of equations (N up to 10), so I got different codes, and compile them, and they seem to work, but I get lots of problems with precision. I mean, the solvers are really very sensitive to small changes of the system.
So, could somebody recommend to me a reliable commandl ine applicat...
Does anyone know what math methods are implemnted by the hardware of the processor for .net? For example, I have an algorithm that makes a lot of use of atan. I can easily write a lookup table for this, but if math.net implements this using an fpu or other hardware extensions, it's not going to be worth it.
...
Hi,
I have two waveforms which are linked by a numerical factor. I need to use optimal scaling (least squares) between the two waveforms to calculate this factor in Matlab. Unfortunately I have no idea how to do this. The two wave forms are seismic signals related by the velocity of the seismic waves, which I'm trying to calculate. Any ...
I need to work out if a massive integer (I mean 20 digits...) is prime.
I'm trying to use the brute-force method, but (of course) I need to use doubles to contain the original number. However, the modulo operator (%) is an integer operator - thus it is useless to me!
Any help would be greatly appreciated,
tf.
...
I am writing a physics engine/simulator which incorporates 3D space flight, planetary/stellar gravitation, ship thrust and relativistic effects. So far, it is going very well, however, one thing that I need help with is the math of the collision detection algorithim.
The iterative simulation of movement that I am using is basically as ...
I'm going to program a fancy (animated) about-box for an app I'm working on. Since this is where programmers are often allowed to shine and play with code, I'm eager to find out what kind of cool algorithms the community has implemented.
The algorithms can be animated fractals, sine blobs, flames, smoke, particle systems etc.
However...
How to find the maximum of two explicit values in MySQL? Something like MAXIMUM(1, @foo).
There are group functions like MAX, MIN, AVG, etc that take column name as an argument and work with result sets. Is it possible to convert two explicit values to a result set and use those functions? Some other ways?
P.S.: I need a max function f...
Hello, I am plotting flight paths between Airports that I have Latitude and Longitude values for onto a Google Map (v3 of the API).
However unlike v2, v3 does not seem to have an option to put a Polyline on the map between two points and have it display as the great-circle flightpath.
So what I was thinking, was that it might be possib...
I want to discretize the DateTime with the resolution of 5 minutes. I did it in C#, but how to convert the following code to MySQL?
DateTime Floor(DateTime dateTime, TimeSpan resolution)
{
return new DateTime
(
timeSpan.Ticks *
(long) Math.Floor
(
((double)dateTime.Ti...
I know the end points of a line segment and the distance/size of the perpendicular end caps I'd like to create but I need to calcuate the end points of the perpendicular line. I've been banging my head against the wall using either 45-45-90 triangles and dot products but I just can't seem to make it come together.
I know the points in b...
I have a numerical method that could return nan or inf if there was an error, and for testing purposed I'd like to temporarily force it to return nan or inf to ensure the situation is being handled correctly. Is there a reliable, compiler-independent way to create values of nan and inf in C?
After googling for about 10 minutes I've only...
Hello,
as a homework assignment, we're writing a software rasterizer. I've noticed my z buffering is not working as well as it should, so I'm trying to debug it by outputting it to the screen. (Black is near, white is far away).
However, I'm getting peculiar values for the z per vertex. This is what I use to transform the points:
floa...
I have a need to write code that will prorate a value across a list, based on the relative weights of "basis" values in the list. Simply dividing the "basis" values by the sum of the "basis" values and then multiplying the factor by the original value to prorate works to a certain degree:
proratedValue = (basis / basisTotal) * proratio...
I'm reading about an algorithm (it's a path-finding algorithm based on A*), and it contains a mathematical symbol I'm unfamiliar with: ∀
Here is the context:
v(s) >= g(s) = min[s'∈pred(s)](v(s') + c(s', s)) ∀s != s[start]
Note: items in [brackets] are supposed to be subscript
Can someone explain the meaning of ∀?
...
I'm trying to implement thinking-sphinx across multiple 'sites' hosted under a single rails application. I'm working with the developer of thinking-sphinx to sort through the finer details and am making good progress, but I need help with a maths problem:
Usually the formula for making a unique ID in a thinking-sphinx search index is to...
I'm using a shopping cart script from a tutorial I came across a while ago, and I need to modify it to calculate sales tax for my state (Pennsylvania). I want it to extract the state, compare it to either Pennsylvania or PA incase someone writes the state shorthand and then multiply the subtotal (for the items.. before shipping is added...