-1

how to get median from two integer like :

I have simple value of minimum and maximum ::=> 25 and 55,

so median from 25 to 55 will be around 37.5, its ok if we got 38 as we need integer

How can I find using jQuery of javascript ?

Php Symfony Guru
  • 137
  • 1
  • 12

1 Answers1

0

You can use the bitwise right shift operator for integer division it will always give the result as an integer value only.

var num1 = 25;
var num2 = 58;
var result = (num1+num2)>>1;
console.log(result);
amrender singh
  • 7,949
  • 3
  • 22
  • 28