Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
EnTerr
Roku Guru

Re: Working with LongInteger

@RenoJim -
pray tell, why are you using LongLong?

I suspect you are "making lemonade" but specifically what kind of thing is exceeding 32 bits? There might be other ways to juice it
0 Kudos
renojim
Community Streaming Expert

Re: Working with LongInteger

I'm counting total pennies in one of my games. It's purely informational and may or may not ever need more than 32 bits. I just figured I'd use LongInteger since it's available. If it weren't and the counter just wrapped around, it would be no big deal.

-JT
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
EnTerr
Roku Guru

Re: Working with LongInteger

If one gets a penny for every second they play, it will take 2^31 seconds or 68 years to reach the horizon and they'll have $21M at that point
(do you offer cash out option? :twisted: )

For counting money though, just use Double - per IEEE it's guaranteed to preserve at least 15 digits during conversion. Which means you can hold amounts up to the US federal budget ($3+ trillion) with precision down to a cent. The nice thing is that even if exceeding that, it will start "failing" in a nice way, i.e. losing the cents like IRS does. Not to mention there is 2 hidden digits precision (it works internally at 17 decimal digit precision equivalent).
0 Kudos
renojim
Community Streaming Expert

Re: Working with LongInteger

But what if it's 1000000 pennies at a time? 😄
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
EnTerr
Roku Guru

Re: Working with LongInteger

"renojim" wrote:
But what if it's 1000000 pennies at a time? 😄

Then you can afford yourself ~2000 of these $10,000 wins.

Or if you switch to Double - which i advocate - then can handle 1,000,000,000 events like the above, which if they happen 1/sec would take 30+ years to lose the penny precision (not to overflow!). And after that, umm... why do you exactly need to pinch every penny? 😛
0 Kudos
renojim
Community Streaming Expert

Re: Working with LongInteger

Nope. I learned long ago that dealing with currency as integers is far safer than using floats of any kind.
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos