I'm not seeing the result I expect with Math.Round.
return Math.Round(99.96535789, 2, MidpointRounding.ToEven); // returning 99.97
As I understand MidpointRounding.ToEven, the 5 in the thousandths position should cause the output to be 99.96. Is this not the case?
I even tried this, but it returned 99.97 as well:
return Math.Round(9...
In our discrete mathematics course in my university, the teacher shows his students the Ackermann function and assign the student to develop the function on paper.
Beside being a benchmark for recursion optimisation, does the Ackermann function has any real uses ?
...
I'm looking for a method to generate a pseudorandom stream with a somewhat odd property - I want clumps of nearby numbers.
The tricky part is, I can only keep a limited amount of state no matter how large the range is. There are algorithms that give a sequence of results with minimal state (linear congruence?)
Clumping means that ...
Hi guys,
according to below 3 Equations
x+y+z=100;
x+y-z=50;
x-y-z=10;
how to get the value of x,y,z with java?
=============================================
String equation1="x+y+z=100;";
String equation2="x+y-z=50;";
String equation3="x-y-z=10;";
int[] SolveEquations(equation1,equation2,equation3){
// to do
//how to do ?
}
=...
Is there a way in Java to get the result from this mathematical expression:
String code = "5+4*(7-15)";
Ie, what's the best way to parse an arithmetic expression?
...
If M is prime, how to choose a and b to minimize collisions?
Also in books it is written that to find the empty slot while quadratic probing in (f(k)+j^2) % M, the hash table has to be at least half empty? Can someone provide me a proof of that?
...
Is there a way to find potential numeric overflows in Java code, using the Eclipse IDE? For example...
long aLong = X * Y * Z;
... where X, Y, and Z are ints and the result may overflow Integer.MAX_VALUE. (Note that, perhaps counter-intuitively, if the result in this example overflows Integer.MAX_VALUE, aLong will be assigned the erro...
How can I round down a number in Javascript?
math.round() doesn't work because it rounds it to the nearest decimal.
I'm not sure if there is a better way of doing it other than breaking it apart at the decimal point at keeping the first bit. There must be...
...
I have a bunch of vectors normal to window surfaces in a 3D modelling software. Projected to the XY-Plane, I would like to know in which direction they are facing, translated to the 8 compass coordinates (North, North-East, East, South-East, South, South-West, West and North-West).
The vectors work like this:
the X axis represents Eas...
Hay Guys, I have quick question.
I have a few floats:
-4.50
+6.25
-8.00
-1.75
How can I change all these to negative floats so they become:
-4.50
-6.25
-8.00
-1.75
Also i need a way to do the reverse
If the float is a negative, make it a positive.
Thanks
...
Hello,
Is there a simple way to do this
if (1 < x && x < 3) { .... }
I want something like this:
if (1 < x < 3) { .... }
I know that the code above is wrong but....
Thanks
...
I wrote a drawing function that draws various on-screen sprites. These sprites can only overlap up to a point. If they have to much overlap, they become too obscured. As a result I need to detect when these sprites are too much overlapped. Luckily, the problem is simplified in that the sprites can be treated as orthogonal rectangles. I'd...
Hi,
I'm doing a division in a JSP and I'd like to round the result - how should I do this?
i.e.
<c:set
var="expiry"
value="${(expire.time - now.time) / (60 * 1000)}"/>
...how do I round the result?
Thanks,
...
I'm interested in implementing an algorithm on the GPU using HLSL, but one of my main concerns is that I would like a variable level of precision. Are there techniques out there to emulate 64bit precision and higher that could be implemented on the GPU.
Thanks!
...
I am writing a program in Processing that transforms complex numbers. However, I want to have a method of taking an input string and calculating the transformation using a complex variable. For example:
1/(z+1)
(z^2)/(z/2)
where z is a complex number. Now, I've looked at JEP and some examples, but I cannot work out if it would allow y...
This is a two part question.
In a reunion of 20 people, there are 48 pairs of people that know each other.
a) Justify why there is, at least, one person who knows, at most, other 4 persons.
b) Suppose there is a single person who knows at most other 4 persons. How many people does that person knows exactly?
I'm unsure about my answe...
from Wikipedia: fourier division.
Here is a screenshot of the same:
(view in full-resolution)
What is the logic behind this algorithm?
I know it can be used to divide very large numbers, but how exactly does it work?
...
What is wrong with my power function?
pow(_,0,1).
pow(X,Y,Z) :-
pow(X,Y-1,X*Z).
?- pow(2,3,Z).
ERROR: Out of global stack
...
I'm trying to figure out a way to algorithmically get the amplitude and phase of a function that has sinusoidal terms in the Maxima computer algebra system. This only applies to steady state (as t -> infinity and the transients decay). For example, a trivial case would be:
f(t) = 1 / w * sin(w * t + theta) + exp(-a * t) + 8
In this ...
I am a student interested in developing a search engine that indexes pages from my country. I have been researching algorithms to use for sometime now and I have identified HITS and PageRank as the best out there. I have decided to go with PageRank since it is more stable than the HITS algorithm (or so I have read).
I have found countle...