Large floats produce serialization errors / data loss

Forums 💬 NodeCanvas ⚙️ Support Large floats produce serialization errors / data loss

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #17686
    zsoik
    Participant

      Using very large constant float values can lead to data loss because serialization does not work for them:

      or

      Repro:
      – Create prefab in library
      – Select prefab in library (do not instantiate in scene)
      – Add blackboard component
      – Add float variable
      – Add a bool variable
      – Add some other variables as you like, actually 😉
      – Set a float value to 100000000000000000000000000
      – Save project
      – Reopen project
      – All blackboard variables gone.

      As graphs are also serialized through the same mechanism, it may also effect them. Quick test:
      – New scene
      – New FSMOwner to scene
      – Add bound graph
      – Create some action nodes with transitions
      – Add a “Set Float” action
      – Set a dynamic variable to 1e+35
      – Try to export graph as JSON
      – No JSON file generated
      – Maybe also serialization in scene fails (save scene + reopen). At least you will get the old version of the graph

      My use case was actually to set a float variable to positive infinity through SetFloat action.

      NC 2.6.3 on Unity 2017.1.1p4

      #17688
      Gavalakis
      Keymaster

        Hello,

        Thanks for the report.
        I am looking at this ASAP and I will let you know!

        #17687
        Gavalakis
        Keymaster

          Hey,
          So, the parsing is fixed. You can open up fsJsonParser.cs and at line #244,

          Change this:

          To this:

          This will take care of the parsing error.
          The second error about serializing “1e+35” is not yet fixed though.

          If you want to set a variable to infinity via the SetFloat action, you can do so by actually writing “Infinity” in the “Value B” to set 🙂
          [attachment file=”SetInfinity.png”]

          Thanks again for the report.

        Viewing 3 posts - 1 through 3 (of 3 total)
        • You must be logged in to reply to this topic.