Is rotation_degrees bugged?

Godot Version

Godot 4.3 Stable

Question

I am trying to rotate a raycast in steps of 9 degrees.
This code prints the correct amounts up until applying 117 degrees.
The raycast.rotation_degrees forces into a float value an messes everything up after that.

func _on_button_pressed() -> void:
	var i:int = int(ray_cast_2d.rotation_degrees)
	printt(wrapi(i + 9, 0, 369), ray_cast_2d.rotation_degrees)
	i = wrapi(i + 9, 0, 369)
	ray_cast_2d.rotation_degrees = i

The output:


9	0
18	9
27	18
36	27
45	36
54	45
63	54
72	63
81	72
90	81
99	90
108	99
117	108
125	116.999992370605

Shouldn’t this all be integers? What am I missing here?

Some more checking reveals this:

func _on_button_pressed() -> void:
	ray_cast_2d.rotation_degrees = 117
	print(ray_cast_2d.rotation_degrees)

And the output:
116.999992370605

It looks like this is a pitfall from the way float values are handled.
See this github issue
And this issue

Yes, you are constrained by the quirks of floating point arithmetic in a binary numeral system.

Additionally, rotation_degrees is a computed property. On set it converts degrees to radians. The inverse on get.