Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Bolt Visual Scripting and Int64

Discussion in 'Editor & General Support' started by mylifeisonebay, Dec 17, 2020.

  1. mylifeisonebay

    mylifeisonebay

    Joined:
    Dec 12, 2020
    Posts:
    7
    Hi all,

    I am new to the unity forum, so I hope this is the best place to put this question: How can I use an int64 variable with Bolt's visual scripting package?

    Currently, I'm writing a game that requires numbers up to x * e ^ 308 which I understand int64 can support, however, Bolt seems to only support up to a standard 32bit int. Any help?

    Edit: To add on some context

    I am very interested in using a big numbers library, but I am unsure how to incorporate that into bolt's visual system. I am also okay with using a mix of C# and visual but I'd rather use as much visual as possible.
     
    Last edited: Dec 17, 2020
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,723
  3. mylifeisonebay

    mylifeisonebay

    Joined:
    Dec 12, 2020
    Posts:
    7
  4. mylifeisonebay

    mylifeisonebay

    Joined:
    Dec 12, 2020
    Posts:
    7
  5. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,723
    So this is the series of steps I believe:
    • Tools -> Bolt -> Unit Options Wizard
    • Press the "+" at the bottom and add the "System" assembly
    • Press Next
    • Press the "+" at the bottom
    • Search for "Long"
    • Select the "Long (In System)" type
    • Click "Generate"
    That should get you Long which should be the same thing as Int64.
     
    haroldo7 likes this.
  6. mylifeisonebay

    mylifeisonebay

    Joined:
    Dec 12, 2020
    Posts:
    7
    This is EXACTLY what I needed! Thank you so much! I didn't realize that "long" was another way to describe Int64 and I swear I was losing my mind. I really really appreciate it!! You've solved two days of painstaking searching (that I obviously didn't do well!)
     
  7. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,723
    Glad that worked for you. Unfortunately That will only get you up to something like 10^18

    If you want to represent numbers up to 1e300 or something, as you properly surmised, you'll need a big numbers type library.

    There is System.Numerics but I don't think Unity includes that by default: https://docs.microsoft.com/en-us/dotnet/api/system.numerics?view=net-5.0

    So you might have to go find a DLL for it or import a separate 3rd party big numbers library. Either way, once you've added that library to your Unity project, you should be able to add it to Bolt in a similar way as we've done here.
     
  8. mylifeisonebay

    mylifeisonebay

    Joined:
    Dec 12, 2020
    Posts:
    7
    Excellent! Since this is technically a separate issue, if I run into problems installing this should I make another thread, or reply here?
     
  9. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,723
    I'd suggest making a different thread for getting a big numbers library working in your project if you have trouble doing so. When you've gotten that into your project then if you have more troubles getting it working with Bolt I'd say return to this thread.
     
  10. mylifeisonebay

    mylifeisonebay

    Joined:
    Dec 12, 2020
    Posts:
    7
    I did want to reply here saying that I may have solved the issue entirely.

    While the long value isn't enough, the double variable should be right? Google tells me it holds 1.8 x 10 ^ 308, which is more than enough for me. I don't know enough about these number formats to know their downside.
     
  11. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,723
    It really depends on what you're trying to do. While technically double can represent numbers that high, how much precision do you need?
    double
    is what is known as a "floating point number" (along with its little sibling
    float
    ). It's called that because the location of the decimal point in the digital representation of the number is variable. It "floats".

    For floating-point numbers, the larger the number being represented, the lower the precision. For
    float
    once the number gets to be around ~16 million, you can no longer individually represent every integer value.

    For example, you can have a float with the value
    16,777,216
    and one with the value
    16,777,218
    but it's impossible to have a float with the value
    16,777,217
    . And forget about anything past the decimal point.

    For
    double
    you get twice as much precision as floats. That pushes this problem further back, but if you are talking about numbers with 100s of digits, you will reach the same problem with
    double
    .

    I wrote an article a while back about how floating points lose precision as they grow larger. You can read it here if you're interested: https://jschiff.com/Something-About-Floats
     
  12. mylifeisonebay

    mylifeisonebay

    Joined:
    Dec 12, 2020
    Posts:
    7
    I'm not sure who you are friend but you have been a wonderful well of knowledge.

    So basically I'm making an incremental game that doesn't require high precision. In fact, i'd prefer if it didn't compute the smaller numbers because for my intents and purposes, they're irrelevant. I thought about using a library that I made myself where I just converted the numbers by hand but it became quite complicated and confusing, mostly because of how unfamiliar it felt.

    Either way, I really appreciate the article you wrote and have bookmarked it. Thank you for your help!!