Mathematically Find Max Value without Conditional Comparison

前端 未结 14 588
暗喜
暗喜 2020-12-03 03:39

----------Updated ------------

codymanix and moonshadow have been a big help thus far. I was able to solve my problem using the equations and instead of using right

14条回答
  •  醉梦人生
    2020-12-03 04:13

    I guess this one would be the most simplest if we manage to find difference between two numbers (only the magnitude not sign)

    max = ((a+b)+|a-b|)/2;
    

    where |a-b| is a magnitude of difference between a and b.

提交回复
热议问题