question avatar image asked

My statistic exceed int32 value limit.

Hi guys.

I'm hitting on a wall! My casino game using a VC which might varied from 0 to hundreds of billion and I want to create a leaderboard with this VC, but most of the integer values used in PlayFab system including Statistic value is int32 (which 2,147,483,647 max)... :(( Any suggestions?

Thank you in advance!

Leaderboards and Statistics
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image
brendan answered

Due to the limitations of some languages/platforms, the statistics are indeed uint32 values. We may in future provide a different form of statistic that's 64 bit (or higher), but if you're specifically asking how to represent values that exceed 32 bits, while maintaining the same granularity (so, being able to differentiate values which are off by 1 from each other), that's not technically possible using 32 bit values. It's possible to store any size value as user data, but (of course) that wouldn't provide you with a leaderboard system for those values. I would have to recommend that you use an external data table for leaderboards, if that's a hard requirement for your title.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total. avatar image commented ·

So it's impossible to store an int64 with PlayFab :(( I'm not surprised.

But I'm thinking of an temporary method using scale number. Let's take an example with scale number is 100: in this case every values submitted to PlayFab will be divided by 100 and every values from PlayFab displayed to user will be multiplied by 100, so this is the scenario:

PlayFab-side: max value is 2,147,483,647
Client-side: max value is 214,748,364,700 (this is enough for me)
Value-updated-to-PlayFab = round ( Value-at-client-side / 100 )

The downside is my number values at client-side can't have tens and digits, ex. 25, 250, 2016, 2150, 10550 is unacceptable and will be rounded to 0, 300, 2000, 2200 and 10600. Anyway, this is acceptable values for me in a casino game which min chip value is 100, but I don't know if there're any possible risks for database or IAP system if I adopt above method?

0 Likes 0 ·
brendan avatar image brendan commented ·

You can store anything you like in user data, including 64 (128, 256, etc) bit values. But the statistics system is 32 bit in order to provide compatibility with all the platforms and languages we support. And yes, when I was saying that larger than 32 bit values with full granularity are therefore not possible, I was indeed meaning that if you were to accept less granular values, you could use the low bits to represent a value that you then modify by something you put in the upper bits - a multiplying factor. Or even simpler, just multiply the statistic by some common value (like 100, as in your case).

The statistics would be stored the same way regardless, and they have no impact on other database tables or any of the economy/purchasing systems. So yes, if you don't need values under 100, you could do it that way.

And again, if in future we hear from more folks that they need larger than 32 bit values in statistics, we can look into adding a feature to support this (breaking up the value into 32 bit "chunks" that we then re-assemble on the back end). One of the primary inputs to our prioritization of future work is the aggregation of feedback from our user community, after all.

1 Like 1 ·
yabatatagames avatar image yabatatagames commented ·

Hi, is the virtual currency also in32?

0 Likes 0 ·
brendan avatar image brendan yabatatagames commented ·

Yes, as stated in the docs (ex:, the virtual currency balances are Int32 values.

0 Likes 0 ·
ildankiamov avatar image ildankiamov commented ·

Is it possible to store float values?

0 Likes 0 ·
brendan avatar image brendan ildankiamov commented ·

As stated, statistics are specifically int32 values. If you want to have a fractional value, you would need to store it as an int32 (potentially by multiplying it by some factor and rounding off, then dividing on the client side, for display).

0 Likes 0 ·
Andrew Garrahan avatar image
Andrew Garrahan answered

Here is the code nerds. You can store a double into int, however you lose a little precision.

     public static int encode(double num)
         int exp = (int)Math.Floor(Math.Log10(num));
         int mantissa = (int)Math.Round((num / Math.Pow(10, exp)) * 100000);
         return exp * 1000000 + mantissa;
     public static double decode(int num)
         double exp = Math.Floor( num/ 1000000f);
         double mantissa = (num - exp * 1000000) / 100000;
         return mantissa * Math.Pow(10, exp);
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.