If i want to insert a number >= 1 trillion into a MySQL database table, what data type must I have the field as? For example, if the number is 1 trillion, this is thought of by PHP as 1E+12, and so is inserted into the database as "1". I hope you understand the question...
PHP does not handle integers above just over 2 billion (excluding custom builds and 64-bit platforms). If you want to handle large numbers use the gmp and bc extensions.
Hello feyd . Thank you for your reply. Sorry, maybe I didn't explain myself properly...
For example, from my script, a number 1.4086919015E+12 is calculated. The problem I am having it inserting this number into the database. Is it possible to force PHP not to return the value in scientific form? I beleive if the number wasn't in scientific form it would insert correctly. This page seems to suggest an unsigned BIGINT column type can hold a value up to 18446744073709551615. Are you saying that if I use the gmp and bc extensions, I can calculate the 1.4086919015E+12 number NOT in scientific form?
PHP cannot natively support such large numbers. It's a 32 bit application. Your result is beyond that possible integer size which results in a floating point number. Floating point allows for a greater range, but less accuracy. GMP and BC are the only solution for keeping calculations looking normal as they use strings for transport.