0 votes

Documentation says that int is in range [-9223372036854775808, 9223372036854775807], but when I set int value to maximum negative value (-9223372036854775808 or hex 8000 0000 0000 0000) it says:

"E 0:00:00.460 toint64: Cannot represent 9223372036854775808 as 64-bit integer, provided value is too big. <C++ Error> Condition "overflow" is true. Returned: sign == 1 ? 9223372036854775807LL : (-9223372036854775807LL - 1) <C++ Source> core/ustring.cpp:1840 @ toint64()"

Why a cant set integer to hex value of 8000 0000 0000 0000. Can someone explain what I what i'm doing wrong here?

Godot version 3.2.4 beta4
in Engine by (244 points)

1 Answer

+1 vote
Best answer

The max positive value of a signed 64-bit int in HEX is 7FFF FFFF FFFF FFFF. So, your hex value is too big by 1.

by (12,475 points)
selected by

Yes, but max negative value is 8000 0000 0000 0000, and it can't be set. If I set int value to hex 8000 0000 0000 0000 (max negative int) Godot returns positive int 9223372036854775807, but if I set int value to max negative int in decimal -9223372036854775808 it returns -9223372036854775807, not a max negative int.

Hmmm... I see that it's possible to successfully set a value in the range of -0x7fff ffff ffff ffff --> 0x7fff ffff ffff ffff, however, the INT64_MIN value of -0x8000 0000 0000 0000 is not accepted.

This feels like a bug to me...

Poking around, it seems likely to have been fixed by this commit:

https://github.com/godotengine/godot/commit/687b127fc569964b600b6ce558ded8d82ec625c7

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.