Why PI != Vector2(PI,0).x

Godot Version

4.4.1

Question

I have this simple script in a blank godot project:

extends Node2D

func _ready() -> void:
	print(PI)
	print(Vector2(PI, 0).x)
	print(PI == Vector2(PI, 0).x)

Which returns:

3.14159265358979
3.14159274101257
false

Why PI has two values. I understand floating point errors but, here I just testing PI as a component from a vector. Why I should change value?

float (PI) is double-precision, in C/C++ it would be double, Vector2 is single-precision.

2 Likes

Well that make sense, thank you

For posterity this part of the docs explain it clearly:

1 Like