infinite-value

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

百般思念 提交于 2019-12-19 19:55:09
问题 I need to simulate a ∞ in PHP. So that min(∞,$number) is always $number . 回答1: I suppose that, for integers, you could use PHP_INT_MAX , the following code : var_dump(PHP_INT_MAX); Gives this output, on my machine : int 2147483647 But you have to be careful ; see Integer overflow (quoting) : If PHP encounters a number beyond the bounds of the integer type, it will be interpreted as a float instead. Also, an operation which results in a number beyond the bounds of the integer type will return

Express mathematical infinity in C#

我的梦境 提交于 2019-12-04 15:26:00
问题 Is it possible to express (mathematical) infinity, positive or negative, in C#? If so, how? 回答1: double.PositiveInfinity double.NegativeInfinity float zero = 0; float positive = 1 / zero; Console.WriteLine(positive); // Outputs "Infinity" float negative = -1 / zero; Console.WriteLine(negative); // Outputs "-Infinity" 回答2: Use the PositiveInfinity and NegativeInfinity constants: double positive = double.PositiveInfinity; double negative = double.NegativeInfinity; 回答3: public const double

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

强颜欢笑 提交于 2019-12-01 18:19:50
I need to simulate a ∞ in PHP. So that min(∞,$number) is always $number . I suppose that, for integers, you could use PHP_INT_MAX , the following code : var_dump(PHP_INT_MAX); Gives this output, on my machine : int 2147483647 But you have to be careful ; see Integer overflow (quoting) : If PHP encounters a number beyond the bounds of the integer type, it will be interpreted as a float instead. Also, an operation which results in a number beyond the bounds of the integer type will return a float instead. And, from the Floating point numbers documentation page : The size of a float is platform