Hello, I am making an astronomical app, and the lack of double precision arithmetic is not allowing me to get the high precision results I need. I know Godot can be compiled with the double precision option, but that is light years away from my capabilities. Is there a place where I can download such a build? Thx.

    I'm not aware of a downloadable build.

    It's not that difficult to make your own build. The instructions are reasonably clear.

    An alternative is to use double precision only in places where it matters (using your own code instead of using the Godot API classes). In the "old days", before there were fast floating point co-processors, that was the standard practice.

      vfung In theory you could use the C# build and do the calculations in C#.
      remember that the visual part of your game and the physical part are different, and in this case let's call the the "metaphysical", it's data that only exists in code, like a voxel or an inventory where the items are defined by ints.

      do the calculations in code, then convert them into something that can be represented on the screen. Like, split your universe into sectors and load one sector at a time, or determine when a star has to be visible or not because it's too far away.

        Jesusemora you could use the C# build and do the calculations in C#.

        You don't need to use C#. Floating point in GDScript is double precision. It's only part of the API that uses single precision.

        I suspect that is great advice for somebody who knows what you are talking about, but I am not a programmer and I have no clue.

        I was hoping doing a double precision build was a common need, and there are sites who post them for others to download.

        • xyz replied to this.

          vfung How do you know you need double precision if you're not a programmer? 😉

            i swear on all my lives there was a scons option for double precision when building Godot from source. looking again, i either dreamed it, it doesn't exist anymore, or i suck at web searching. someone let me know if i'm crazy.

            edit: and the answer is #3:
            https://docs.godotengine.org/en/stable/contributing/development/compiling/compiling_with_dotnet.html#double-precision-support-real-t-is-double
            i think because this is only mentioned in the "Compiling for .NET" doc, its a windows only feature. that or it's another case of strangely obscured documentation. i haven't tried it out yet.

            edit #2: its come to my attention .NET is cross platform.

              vfung Hi there, I changed the tags as this seems to be more asking for help than a project. 👍

              vfung I know Godot can be compiled with the double precision option, but that is light years away from my capabilities. Is there a place where I can download such a build?

              I'm in a similar position to you right now. I don't need double precision, but I want to play with soft physics in Godot 4.3, and for that I also need to compile an engine. There are no ready compiled engines available anywhere. Looks like we have only two choices:

              1. Wait for some good Samaritan to compile an engine with the necessary settings and share it with us.
              2. Try to master compilation on our own.

              It is very difficult to find good Samaritans in the modern world. Self-compilation can make us independent (relatively of course), although it is really not easy at all. But presumably it is possible.

              But you have to take into account that GDExtension won't work or have to be recompiled too.

              What version of Godot do you need and for what OS?

              DaveTheCoder It's not that difficult to make your own build. The instructions are reasonably clear.

              It's not that hard to do when you already have a customized and working toolkit, and experience with it. It requires installing and setting up weird programs that wouldn't be needed in peacetime.

              Changing a barrel in a machine gun is not hard, but it may be difficult the first time.

              xyz How do you know you need double precision if you're not a programmer?

              Here is a detailed explanation of why double precision is needed. In short, it is the astronomers' custom.

              Jesusemora In theory you could use the C# build and do the calculations in C#.

              packrat i swear on all my lives there was a scons option for double precision when building Godot from source. looking again, i either dreamed it, it doesn't exist anymore, or i suck at web searching. someone let me know if i'm crazy.

              It seems to be possible to compile from the regular version.

              Translated with DeepL.com (free version)

                As someone stated above, Godot's float type is already double precision. So all large distance calculations can be done with it, and you almost never need double precision for rendering stuff on screen.

                Regarding compiling - building Godot is almost trivial, thanks to SCons. No special knowledge needed. Just download the required software as stated in the instructions, type a single line into the console, press enter and wait for the executable to materialize 🙂

                  xyz So all large distance calculations can be done with it, and you almost never need double precision for rendering stuff on screen.

                  This is the article that disagrees with you:

                  Close to the scene origin this looks totally fine, but once we move this same scene 10,000 kilometers away something terrible happens. The Godots clump together and the character teleports from point to point. The diameter of the earth is 12,742 km for reference.

                  xyz Just download the required software as stated in the instructions

                  Tomcat It requires installing and setting up weird programs that wouldn't be needed in peacetime.

                  I once built ArmorPaint according to the instructions, everything seemed fine. But when I wanted to do it again, one of the required programs asked me to register. So it's not that simple.

                  I also remembered, there were problems when building in Win 7, it required at least Win 10. I don't remember how I solved it.

                    Tomcat This is the article that disagrees with you:

                    From that article:

                    By default Godot uses single-precision floating point numbers to store things like object positions. While GDScript typically allows users to do user-space calculations with double precision, those calculations get truncated as soon as they are stored in Godot internal objects (like Vector3’s).

                    Then for data requiring double precision, don't use Vector3, Node3D, etc. Use only the primitive data types like float and int, and create custom classes using only those types. For some objects, you may need two copies: a double precision copy for real world calculations, and a single precision copy (using Vector3's) for displaying.

                    I haven't thought this through, and there may be obstacles, such as using the physics engine without using Godot's physics objects.

                    It will take effort, but so does making a custom build from source code. And with a custom build, you'll need to rebuild every time a new version is released, if you want to keep up with that.

                      DaveTheCoder And with a custom build, you'll need to rebuild when a new version is released, if you want to keep up with that.

                      Yep. Obviously, there's no easy and simple solution.

                      what is even double precision? like x.xx?

                        kuligs2 what is even double precision? like x.xx?

                        I gave a link to the article above.

                        This is the range where individual integer values can be represented in a floating-point number:

                        • Single-precision float range (represent all integers): Between -16,777,216 and 16,777,216
                        • Double-precision float range (represent all integers): Between -9 quadrillon and 9 quadrillon

                        It is needed for astronomical calculations

                          Tomcat i get that it is needed for astro stuff.. but can you not abstracterize the numbers? like you want something with 100 zeros you just write it like maybe 1e100 then do some conversion maths from string/obj to some number and or something.. i mean you dont have to store the whole number in a var or do you? i mean 5 chars in a string is less bytes than 1 with 100 zeros..??

                            kuligs2 like you want something with 100 zeros you just write it like maybe 1e100 then do some conversion maths from string/obj to some number and or something

                            That's possible, but it would make the math calculations extremely slow. And you wouldn't be able to use Godot's built-in features like CharacterBody3D, collisions and the physics engine.

                            Godot's primitive float variables and floating point operations are already double precision. The problem is that when using built-in objects such as CharacterBody3D in a standard Godot build, the position, velocity and other properties get truncated to single precision. So you would have to avoid using those objects, and do your own physics calculations.

                            Maybe the ideal solution is a double precision physics engine plugin.

                            I wonder how Unity and Unreal handle this.

                              kuligs2 but can you not abstracterize the numbers?

                              That's not really my topic. I just joined the discussion of Godot compilation possibilities with extended non-standard features. Although my project may need large numbers, but this is in the very long term. Then I will look for a solution.

                              DaveTheCoder Maybe the ideal solution is a double precision physics engine plugin.

                              Can a plugin replace the built-in solution? I'm interested in the question "in general" — I came across a statement that the physics engine should be integrated into the kernel and an extension won't help in this situation.