I am doing some numerical optimization on a scientific application. One thing I noticed is that GCC will optim
How can the following function be implemented in various languages? Calculate the (x,y) point on the circumfe
I'm trying to round BigDecimal values up, to two decimal places. I'm using BigDecimal rounded = va
The hash of infinity in Python has digits matching pi: >>> inf = float('inf') >>>
I am to show that log(n!) = Θ(n·log(n)). A hint was given that I should show the upper bound with nn and sh
How can I round down a number in JavaScript? math.round() doesn't work because it rounds it to the neare
I want to ensure that a division of integers is always rounded up if necessary. Is there a better way than thi
For example, int result; result = 125/100; or result = 43/100; Will result always be the floor of the
Python's math module contain handy functions like floor & ceil. These functions take a floating point
I need to generate a uniformly random point within a circle of radius R. I realize that by just picking a uni
Imagine two positive integers A and B. I want to combine these two into a single integer C. There can be no
The following code does work how I need it to, but it's ugly, excessive or a number of other things. I&ap
I've been poring through .NET disassemblies and the GCC source code, but can't seem to find anywhere
What is the most efficient way given to raise an integer to the power of another integer in C? // 2^3 pow(2,3
Is there a built-in or standard library method in Python to calculate the arithmetic mean (one type of average
For example: 9 / 5 #=> 1 but I expected 1.8. How can I get the correct decimal (non-integer) result? Wh
Having a list of points, how do I find if they are in clockwise order? For example: point[0] = (5,0) point[1
There have been several questions posted to SO about floating-point representation. For example, the decimal n
According to Google Calculator (-13) % 64 is 51. According to Javascript (see this JSBin) it is -13. How do