# [Unity/Question] How to make a buy 1/10/100/Max button ?

5 posts

 Hello, I dont know if i have posted this thread in right place.... Just like the title, i am making an idle game and have some problems with that. I am sure that you know this button. Buy "the number" of building/or something else that generate main resources in game. 1. I already make buy 1/10/100 and it work well, but then 1000, the number display "infinity". I am using double type so there is no way the cost for the building >= E308. In my calculate, x1000 would cost E41 resources. So i dunno it's display "Infinity" =.=" 2. Any ideas for Max button ? Just dont know how it work =.= Thanks for any help >:D< [Edited] Cost = Mathf.Round ((float)BaseCost * Mathf.Pow ((float)Multiplier, Count)); Here is the code made problem. when count >=907 so the Cost is >=E308. If you run the code in question with a debugger what does the debugger say the value of `Cost` is? > *Originally posted by **[EndlessSporadic](/forums/4/topics/836692?page=1#11407070)**:* > If you run the code in question with a debugger what does the debugger say the value of `Cost` is? Yes, i have. When buying 906 building, the cost is 4E36, and just buy 1, the cost wil go to infinity value You've hit the maximum value storable by a double. You need to get BigRational or BigInteger. [Edit, some hours later and not from mobile] I've been using [Koopakiller's Numerics](https://numerics.codeplex.com) package although I've made some heavy modifications to it to better support what I'm doing (an idle game of course!) such as support for creating a BigRational from a float or double. I thought I did some other stuff like cube root...ah, the log10 is in BigInteger (BigRational is two BigInts) and just does a dumb "how many characters in the string?" count, not a true log10. You can check that out here: https://github.com/Draco18s/IdleArtificer/tree/master/Assets/draco18s/util/Koopakiller.Numerics I've attempted to send bug-fixes upstream, but they remain open and unacknowleged. > *Originally posted by **[Draco18s](/forums/4/topics/836692?page=1#11410184)**:* > You've hit the maximum value storable by a double. You need to get BigRational or BigInteger. > [Edit, some hours later and not from mobile] > I've been using [Koopakiller's Numerics](https://numerics.codeplex.com) package although I've made some heavy modifications to it to better support what I'm doing (an idle game of course!) such as support for creating a BigRational from a float or double. I thought I did some other stuff like cube root...ah, the log10 is in BigInteger (BigRational is two BigInts) and just does a dumb "how many characters in the string?" count, not a true log10. > > You can check that out here: > https://github.com/Draco18s/IdleArtificer/tree/master/Assets/draco18s/util/Koopakiller.Numerics > > I've attempted to send bug-fixes upstream, but they remain open and unacknowleged. Nice, this is very useful for me, lol, you saved my life <3