Does GDscript let you make an infinite number value?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By JTJonny
:warning: Old Version Published before Godot 3 was released.

I don’t really need it, but is there a way to replace a large test number with a built-in GDscript infinite value

		var lowestGoalDistance = 10000000000000
		var closestGoal
		for fG in foundGoals:			
			if fG.distance_to(start) < lowestGoalDistance:
				lowestGoalDistance = fG.distance_to(start) 
				closestGoal = fG
		goal = closestGoal
:bust_in_silhouette: Reply From: eye776

AFAIK, such values aren’t defined anywhere in the code.
I used these two values myself

const PositiveInfinity = 3.402823e+38
const NegativeInfinity = -2.802597e-45

They seem to work alright in my own scripts, and GDScript seems to parse them alright.
If anyone knows this to be wrong, please say so.

Can I ask how does that work?

PLyczkowski | 2016-10-15 16:21

Now there is INF (and -INF)

Chrisstar | 2019-10-04 08:37

:bust_in_silhouette: Reply From: Caderikor

Build v3.1.1

INF = 1. #INFA positive infinity. (For negative infinity, use -INF).

NAN = 1. #QNANMacro constant that expands to an expression of type float that represents a NaN.

The NaN values are used to identify undefined or non-representable values for floating-point elements, such as the square root of negative numbers or the result of 0/0.