Top "Math" questions

Math involves the manipulation of numbers within a program.

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 …

c# java math
How to round a number to significant figures in Python

I need to round a float to be displayed in a UI. E.g, to one significant figure: 1234 -> 1000 0.12 …

python math rounding
Is log(n!) = Θ(n·log(n))?

I am to show that log(n!) = Θ(n·log(n)). A hint was given that I should show the upper …

algorithm math recursion complexity-theory big-o
Rounding BigDecimal to *always* have two decimal places

I'm trying to round BigDecimal values up, to two decimal places. I'm using BigDecimal rounded = value.round(new MathContext(2, RoundingMode.…

java math bigdecimal rounding
How do I calculate the normal vector of a line segment?

Suppose I have a line segment going from (x1,y1) to (x2,y2). How do I calculate the normal vector …

math geometry vector
Algorithm to find Largest prime factor of a number

What is the best approach to calculating the largest prime factor of a number? I'm thinking the most efficient would …

algorithm math prime-factoring
Division of integers in Java

This is a basic question but I can't find an answer. I've looked into floating point arithmetic and a few …

java math floating-point long-integer println
numpy max vs amax vs maximum

numpy has three different functions which seem like they can be used for the same things --- except that numpy.…

python numpy math max
Python math module

Whenever I try to use any of the built-in functions of Python's exponentiation and logarithms module, I get an error …

python math module import logarithm
How can I round down a number in Javascript?

How can I round down a number in JavaScript? math.round() doesn't work because it rounds it to the nearest …

javascript math rounding