Tag: math

59 votes
30 answers
473 views
Calculate distance between two latitude-longitude points? (Haversine formula)

How do I calculate the distance between two points specified by latitude and longitude? For clarification, I&

avatar
Forrest
0 1 0 9
asked 07 September, 2021
67 votes
21 answers
1.8K views
What is JavaScript's highest integer value that a number can go to without losing precision?

Is this defined by the language? Is there a defined maximum? Is it different in different browsers?

avatar
Keith
0 1 0 9
asked 07 September, 2021
52 votes
18 answers
1.7K views
How to perform an integer division, and separately get the remainder, in JavaScript?

In JavaScript, how do I get: The whole number of times a given integer goes into another? The remainder?

avatar
Dusty
0 1 0 9
asked 07 September, 2021
62 votes
30 answers
1.1K views
Easy interview question got harder: given numbers 1..100, find the missing number(s) given exactly k are missing

I had an interesting job interview experience a while back. The question started really easy: Q1: We have a b

avatar
Kurtis
0 1 0 9
asked 07 September, 2021
53 votes
18 answers
784 views
How can I check for NaN values?

float('nan') results in Nan (not a number). But how do I check for it? Should be very easy, but I ca

avatar
Dwain
0 1 0 9
asked 07 September, 2021
56 votes
30 answers
436 views
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 ove

avatar
Juliane
0 1 0 9
asked 07 September, 2021
55 votes
30 answers
1K views
Fastest way to determine if an integer's square root is an integer

I'm looking for the fastest way to determine if a long value is a perfect square (i.e. its square root is

avatar
Margo
0 1 0 9
asked 07 September, 2021
61 votes
30 answers
1.4K views
Is floating point math broken?

Consider the following code: 0.1 + 0.2 == 0.3 -> false 0.1 + 0.2 -> 0.30000000000000004

avatar
Dwain
0 1 0 9
asked 07 September, 2021
59 votes
3 answers
1.6K views
How does the HyperLogLog algorithm work?

I've been learning about different algorithms in my spare time recently, and one that I came across which

avatar
Serina
0 1 0 9
asked 07 September, 2021