What error?
I assure you, double.PositiveInfinity and NegativeInfinity exist:
https://docs.microsoft.com/en-us/dotnet/api/system.double.positiveinfinity?view=netframework-4.7.2
I’m not certain what you mean by “handle float and int”… but I don’t want to go and think I gave you some panacea by introducing you to double in this way.
Really, on the technical level, it’s like this.
All numeric types represent numbers in different ways and will have different limitations/behaviour as a result.
A float is a 32-bit signed floating point number. By float it means that the radix (decimal point) is “floating”… basically it’s binary scientific notation fit into 32-bits.
A double is really just a 64-bit version of a float (float is also known as a ‘single’). I guess you could say a double can “handle” a float, since they follow the same rule sets.
Both floats and doubles have this behaviour in that instead of having a true “range” of number it can represent. float can not actually represent all numbers between MinValue and MaxValue… rather instead it can represent numbers of a specific significant value range within those boundaries. For example…
6877900000 - valid float
6077900001 - NOT a valid float
A float has 24 significant binary bits of precision… which is about 6-9 digits in decimal/base10.
A double has 53 significant binary bits of precision… which is about 15-17 digits in decimal
int on the other hand can only represent whole numbers. No fractions. And it can represent all whole number between its MinValue and MaxValue.
Thing is if you look at the int’s maxvalue of ‘2147483647’ and minvalue of ‘-2147483648’, both of which are 31 bits long. You’ll see that 31 < the 53 sig values available to double. So thusly an int will fit within the behavioural constraints of double.
A double can therefore represent the full range of int values.
But it comes at the limitations of double… such as its arithmetic performance differences (usually hardware dependent), as well as the fact floats/doubles suffer from what is called float error. So just because double can fit an int, it doesn’t mean you should just use a double.
It’s just that if you have to cast an int to a double… it’s no problem. You don’t have to worry about the cast failing.