Search Unity

Very high int values turning negative

Discussion in 'Editor & General Support' started by Yash987654321, May 4, 2015.

  1. Yash987654321

    Yash987654321

    Joined:
    Oct 22, 2014
    Posts:
    729
    and Finally, My project is completely destroyed.
    Thankfully I have made it's Backup before messing with numbers.....
    Do Android support int64/long
     
  2. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,148
    It's rather unreasonable to store so many digits in a single numeric type. The user won't know if it's broken up.

    --edited

    More memory won't be the answer to every problem. :p
     
    Last edited: May 5, 2015
    Kiwasi likes this.
  3. Yash987654321

    Yash987654321

    Joined:
    Oct 22, 2014
    Posts:
    729
    HeHe I am just a 12 years old awesome kid dev and my project isn't using a single thing that effects the performance much. Game was ready (before discovering the Int limit)
    My game is giving great performance! so remove hardware please :)
     
  4. Yash987654321

    Yash987654321

    Joined:
    Oct 22, 2014
    Posts:
    729
    sometime in past you were also like me low knowledge of development
     
  5. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    As a general rule removing hardware makes your game unplayable. While there are plenty of people working on VR technology, no one has yet built a VCPU.
     
    GibTreaty and Ryiah like this.
  6. Yash987654321

    Yash987654321

    Joined:
    Oct 22, 2014
    Posts:
    729
    I meant to remove hardware from his post :p
     
  7. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Yes, int64 is supported on all platforms. It has nothing to do with 64-bit processing capability but rather represents the memory footprint of the number.
     
    Ryiah and Kiwasi like this.
  8. Yash987654321

    Yash987654321

    Joined:
    Oct 22, 2014
    Posts:
    729
    so it will kinda reduce the performance. So now i have no choice but keep lesser values. I may use strings after short values to represent them long like 10000000 = " M"
     
    Tomnnn likes this.
  9. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,148
    @Yash987654321 to be fair I was talking about the questions you've yet to ask and the problems you've yet to run into. It's fine if you're a newer & younger developer to not know everything, but your design decisions could bring more involved games to their knees. A lovely expression for saying that not very well designed or performant things will annihilate your framerate.

    But we'll all be here to help if and when that ever happens :D

    How many 64bit ints could a woodchuck chuck if a woodchuck had 3072MB of RAM?

    Probably a lot... but for design and performance reasons, it might be better to not encourage people to design things with the biggest data structures they have available until they overflow :p

    Now yer gettin' it! I'd also suggest scientific notation, so you can shorthand represent a number with any arbitrary number of digits.

    10e123456
     
  10. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Yeah, just in the scripting forum please.

    Switching a few key pieces of data to int64 will barely make a difference to your performance. But it sounds like you've got a ton of other problems going on, if you keep managing to completely break your project.

    All that said, it wouldn't hurt you to be a little nicer to the volunteers that are trying to help you.
     
  11. Yash987654321

    Yash987654321

    Joined:
    Oct 22, 2014
    Posts:
    729
    i think only floats can be converted in Es and all.
     
  12. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,804
    Technically easy or not I have always hated games that show very high numbers during combat etc. as it totally devalues the meaning of them. I guess some people like it that multiple digit numbers flood the screen when hitting mobs or scoring points but I always disable them with options/mod if possible. Same thing mostly for highscores that go beyond million or billion, at some point you just stop caring.
     
  13. Wrymnn

    Wrymnn

    Joined:
    Sep 24, 2014
    Posts:
    380
    You use the array for calculation of big numbers (Bigger than Long), or you convert your big number to string and do calculations like that. But that will be very slow, which I`m talking from experience.

    And store it however you want.
     
  14. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    But he already has overflowed, which was the point of this thread. :)

    384,000,000 if there was nothing else stored in ram. :)
     
    Tomnnn likes this.
  15. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,148
    I picked that number because my phone has like 2.7GB of RAM. It had more, but then the lollipop update happened.

    I wonder how far we are from int5120
     
  16. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,441
    Keep in mind it was also quite common in games to just pad a 0 or two to the end of a stat to make the numbers feel bigger and more meaningful.

    So adding 10 points or even 100 points could be just adding 1 to the actual internal value. So to a signed int that caps out at a little over 2 billion could represent 20 billion or even 200 billion and a short int can now handle 3,276,700 if there is no value less than 100.
     
  17. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,145
    Or use an alternative implementation. Saw this one linked in a Unity Answers response.

    http://biginteger.codeplex.com/
     
  18. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    http://scrypt.codeplex.com

    That's an RSA Encryption library I wrote for Silverlight 3 and Windows Phone as Microsoft didn't include RSA in Silverlight at the time and Silverlight 3 was based on .NET 3.5 and therefor didn't have BigInteger so I used (and credited) a third party BigInteger library. I had to fix a fair number of bugs in it but it was very similar in that it stored the number as a byte array and used bit shifting for the operators. If you do look at that, don't laugh at any shoddy code... that was my first ever attempt at C# since I had spent years at a company that was strictly VB .NET. :/

    Edit: Also kindly ignore the fact that evidently people have found uses for Scrypt that I'd never thought of and with WP being on version 8 and Silverlight being dead for all intents and purposes, conversations / discussion / issues have gone on around it that I was totally unaware of. :( Guess I should have paid attention.
     
    Last edited: May 5, 2015
  19. darkhog

    darkhog

    Joined:
    Dec 4, 2012
    Posts:
    2,218
    Lol remember that! But forgot if it was screensaver or one of these programs that allow for virtual destruction of your screen in variety of ways. Speaking of which, I'd need one.
     
    MD_Reptile likes this.
  20. Yash987654321

    Yash987654321

    Joined:
    Oct 22, 2014
    Posts:
    729
    Sorry for waking up a 2 months dead post but here are the scripts. I really don't understand what was going in the script. And don't judge my on the bases of this, I have learnt a lot form that time :)
     

    Attached Files:

  21. yoonitee

    yoonitee

    Joined:
    Jun 27, 2013
    Posts:
    2,363
    Can you use a long instead of an int? Which is 64bit?
    Interesting, you would only be able to have up to about 4.2 million dollars with an int.
    But about 18.4 quadrillion dollars with a long. Which is just enough as some people estimate the cost of everything on earth as about 3 quadrillion dollars. Until inflation in a few years in which case your game will explode.
     
    Platon092009 and Yash987654321 like this.