I want to know what is the real value of mathf.infinity? i want to know what number unity uses to represent infinity. is it possible to assign this number using a numeric literal to a variable?

As far as I'm aware, Mathf.Infinity simply *doesn't have* a "normal" numerical equivalent, so no - it's not possible to assign it using a numeric literal.

You can directly assign it to a variable using the Mathf.Infinity constant, or you can have it returned as a result of by dividing by zero, or by exceeding float.MaxValue in an operation, however you can't subsequently subtract from this value to return to normal numeric values.

I can't really understand why you'd want to try and equate it with a real number, because then by definition it would not be infinity, it would be that number! I'm not sure whether you're trying to solve a particular problem, but it doesn't make sense to use anything other than the actual Infinity constant that is already provided.

Mathf.Infinity takes its value directly from float.PositiveInfinity which can be looked up in the MSDN reference.

PositiveInfinity is one of three "special values" that can be assigned to a float variable, in addition to the normal numeric range of values.

The other values are NegativeInfinity and Not a Number (NaN) (these also do not have a real numeric value equivalent!).

ok the answer is the infinity number is a constant representing the infinity and it's defined in the design of the floating point calculation hardware and is one of the many numbers that can be created using 32 bits. it's a normal 32 bit series of number but computer knows about it and knows it's infinity. in some computers infinity related calculations are software emulated but in most machines it's done in hardware. in high level languages compiler itself handles it but in older languages like see it's simply a macro and you really can assign it to a variable in assembly but when you do calculations on it the computer will produce correct results so infinity+1 = infinity. be careful it's not possible to check if (a == float.posetiveInfinity) you should use functions like isInfinity to check for that. when i said compiler handles it i meant that there are constant in the language itself that represent the infinity and -infinity and nan numbers so you don't need to know the set of bits that they mean INF or -INF. for having negative zero you can just type -0. don't worry about infinity because you can not assign it using numeric literals and there is not any way to get infinity as a result from a+b :)

Looks like this post is old, but figured I’d add to this so people know exactly what Infinity is.

Infinity is the highest value that a floating point number can represent. Floating points are a little weird and complicated, but the formulas in the other posts calculate the highest possible value of a floating point number. float.MaxValue should actually be the same as Mathf.Infinity, but someone can correct me if I’m wrong.

visual c# says: 3.402823 * Mathf.Pow(10, 38)

which unity too can handle as a number

unity regards this as inifinity: 3.402823 * Mathf.Pow(10, 39)

(both using javascript or c#)

tried adding and subtracting ones from both but i couldn't get to infinity nor could i get away from it

(3.402823 * Mathf.Pow(10, 39)) - (3.402823 * Mathf.Pow(10, 38))

is still infinity

so i assume you could use this number: 3.402823 * Mathf.Pow(10, 38)