tagged [math]

How to calculate modulus of large numbers?

How to calculate modulus of large numbers? How to calculate modulus of 5^55 modulus 221 without much use of calculator? I guess there are some simple principles in number theory in cryptography to cal...

18 Aug at 19:29

Round Up a double to int

Round Up a double to int I have a number ("double") from int/int (such as 10/3). What's the best way to Approximation by Excess and convert it to int on C#?

15 Feb at 15:57

How can I remove the decimal part from JavaScript number?

How can I remove the decimal part from JavaScript number? I have the results of a division and I wish to discard the decimal portion of the resultant number. How can I do this?

What's the difference between “mod” and “remainder”?

What's the difference between “mod” and “remainder”? My friend said that there are differences between "mod" and "remainder". If so, what are those differences in C and C++? Does '%' mean either "mod"...

1 Jul at 11:54

JavaScript math, round to two decimal places

JavaScript math, round to two decimal places I have the following JavaScript syntax: This rounds up to the whole number. How can I return the result with two decimal places?

1 Nov at 03:28

Difference between Math.Floor() and Math.Truncate()

Difference between Math.Floor() and Math.Truncate() What is the difference between [Math.Floor()](http://msdn.microsoft.com/en-us/library/9a6a2sxy.aspx) and [Math.Truncate()](http://msdn.microsoft.com...

25 Feb at 17:42

Simple maths in Objective-C producing unexpected results

Simple maths in Objective-C producing unexpected results I'm doing the following in Objective-C and expecting 180 as the output but I'm getting 150. Can anyone explain what I'm doing wrong? `(360 / 10...

4 Apr at 14:50

What is the easiest way to subtract time in C#?

What is the easiest way to subtract time in C#? I'm trying to put together a tool that will help me make work schedules. What is the easiest way to solve the following? - - - and so on.

7 Jan at 11:56

How to get whole and decimal part of a number?

How to get whole and decimal part of a number? Given, say, 1.25 - how do I get "1" and ."25" parts of this number? I need to check if the decimal part is .0, .25, .5, or .75.

8 Jul at 02:35

Infinite integer in Python

Infinite integer in Python Python 3 has `float('inf')` and `Decimal('Infinity')` but no `int('inf')`. So, why a number representing the infinite set of integers is missing in the language? Is `int('in...

8 Feb at 07:42

minimum double value in C/C++

minimum double value in C/C++ Is there a standard and/or portable way to represent the smallest negative value (e.g. to use negative infinity) in a C(++) program? DBL_MIN in float.h is the smallest nu...

20 Jul at 13:23

Check if a number is a perfect square

Check if a number is a perfect square How could I check if a number is a perfect square? Speed is of no concern, for now, just working. --- [Integer square root in python](https://stackoverflow.com/qu...

17 Feb at 14:55

What is the difference between '/' and '//' when used for division?

What is the difference between '/' and '//' when used for division? Is there a benefit to using one over the other? In Python 2, they both seem to return the same results:

Return start and end of year given any year

Return start and end of year given any year I need two or one (out) C# method that will take any datetime and return the start date of year and end date of year for that year.

How can I get a count of the total number of digits in a number?

How can I get a count of the total number of digits in a number? How can I get a count of the total number of digits of a number in C#? For example, the number 887979789 has 9 digits.

19 Sep at 22:18

PHP - Large Integer mod calculation

PHP - Large Integer mod calculation I need to calculate modulus with large number like : It's not working... because $largenum is too big for an int in PHP. Any idea how to do this ?

16 Jun at 09:20

How do I find the distance between two points?

How do I find the distance between two points? Let's say I have x1, y1 and also x2, y2. How can I find the distance between them? It's a simple math function, but is there a snippet of this online?

8 Mar at 04:33

Evaluate string with math operators

Evaluate string with math operators Is there an easy way to evaluate strings like `"(4+8)*2"` So that you'd get the int value of 24? Or is there a lot of work needed to get this done...?

10 May at 17:38

How do I get a decimal value when using the division operator in Python?

How do I get a decimal value when using the division operator in Python? For example, the standard division symbol '/' rounds to zero: However, I want it to return 0.04. What do I use?

What's the quickest way to compute log2 of an integer in C#?

What's the quickest way to compute log2 of an integer in C#? How can I most efficiently count the number of bits required by an integer (log base 2) in C#? For example:

23 Jan at 10:19

Why doesn't Math.Round return an int?

Why doesn't Math.Round return an int? In C#, why don't the rounding math functions Floor, Ceiling and Round return an `int`? Considering the result of the function will always be an integer, why does ...

8 Feb at 05:16

Determine Whether Two Date Ranges Overlap

Determine Whether Two Date Ranges Overlap Given two date ranges, what is the simplest or most efficient way to determine whether the two date ranges overlap? As an example, suppose we have ranges deno...

29 Jan at 02:7

How to sum array of numbers in Ruby?

How to sum array of numbers in Ruby? I have an array of integers. For example: Is there any nice way to get the sum of them? I know, that would work.

22 Feb at 03:11

Popularity algorithm

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...

28 Aug at 14:26

Why does Decimal.Divide(int, int) work, but not (int / int)?

Why does Decimal.Divide(int, int) work, but not (int / int)? How come dividing two 32 bit int numbers as ( int / int ) returns to me `0`, but if I use `Decimal.Divide()` I get the correct answer? I'm ...

3 Mar at 16:25