B
B
BonBon Slick2020-08-04 21:41:56
Mathematics
BonBon Slick, 2020-08-04 21:41:56

Find the middle number in the difference between 2 numbers?

2 indices
1st let = 70.05
2nd = 62.43

What you need

70.05-62.43=7.62
7.62 / 2=3.81

The number we need is the minimum of two numbers (62.43) + half the difference (3.81).

It's okay if the second number was always less, but there is a chance that it will be higher.
Therefore, we must add another comparison of which of the numbers is smaller, and add the difference to it.

You need to check it in JS.

Perhaps there is a formula for what I want or special methods for example Math api?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AnT, 2020-08-04
@BonBonSlick

Um... Why was all this necessary, if you can simply do it to calculate the average (70.05 + 62.43) / 2and not worry at all about which number is less?
I don't see even the slightest explanation in your statement of the problem why you decided to "scratch the right ear with the left foot" like this, that is, to go along some strange long detour through "half the difference" and "addition with the minimum". Why did you need it?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question