Most efficient way to find smallest of 3 numbers Java?

后端 未结 17 2286
故里飘歌
故里飘歌 2020-12-14 05:44

I have an algorithm written in Java that I would like to make more efficient. A part that I think could be made more efficient is finding the smallest of 3 numbers. Currentl

17条回答
  •  南笙
    南笙 (楼主)
    2020-12-14 06:05

    double smallest = a;
    if (smallest > b) smallest = b;
    if (smallest > c) smallest = c;
    

    Not necessarily faster than your code.

提交回复
热议问题