Is there something that's larger than any numbers in PHP?

前端 未结 9 1535
谎友^
谎友^ 2021-01-19 03:12

I need to simulate a ∞ in PHP.

So that min(∞,$number) is always $number.

9条回答
  •  北恋
    北恋 (楼主)
    2021-01-19 04:00

    In Perl you can use

    $INF = 9**9E9;
    

    which is larger than any value you can store in IEEE floating point numbers. And that really works as intended: any non-infinite number will be smaller than $INF:

    $N < $INF
    

    is true for any "normal" number $N.

    Maybe you use it in PHP too?

提交回复
热议问题