Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
![](/static/devrant/img/pipeless-devrant-banner-white.png)
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
With PHP you need to use the 64 bit version to get 64 bit integers.
If your host can't provide that you have to use strings (and the bc math extension if you wish to operate on the numbers).
Since PHP retardedly converts numbers that are bigger than PHP_INT_MAX to float i would recommend that you always use bc math for large values (it prevents nasty surprises when your integers are silently cast to float and rounding errors start creeping in). -
As for mongo, it is up to you to decide what to put in a collection, a good way to get a bit better control is to use bson for your data (then you can explicitly specify the types), or convert from json instead of from php arrays. (then you can get some control over the types by for example stripping quotes from your big numbers (which would be strings in php)
-
@GamerFac3 Mongo is limited to 64 bit integers though, and 128bit floats so it might be a good idea to store big integer values as strings there as well.
-
@itsnotmyfault They aren't too big. I just got a problem that int32 cannot be used in java
Related Rants
Did you know that theres no real long in php (if so, please tell me how to cast..)?
And did you know that mongodb decides what it puts into it's collection?
I have no idea how to force it to set an int64 instead of int32..
undefined
mongodb
int64
php