Influence of 32-bit and 64-bit on APIs: andriod, IOS, and JavaScript

Source: Internet
Author: User
Tags php web server
Common Operating Systems:

Android: only 32-bit

IOS: only 32-bit

Linux Server (centos, Ubuntu, RedHat, etc.): 64-bit (used by most companies), 32-bit (obsolete)

Windows PC: 64-bit, 32-bit

 

Common Software:

Android app: Java or C ++. If Java is used and OS is irrelevant, Int Is 64-bit. If C ++ is used, it is to be verified.

IOS app: Object C, OS-related. Int Is 32 bits.

PHP: OS-related. The compiling and installation are the same as those on the server. The Int value is 64-bit or 32-bit.

MySQL: OS-independent. Int Is 64-bit.

Javascript in 32-bit browsers (chrome and Firefox): about trillion, to be determined, no authoritative documentation found

Javascript in 64-bit browsers (waterfox): about trillion, to be determined, no authoritative documentation found

 
VaR A = 9000000000000001; alert (A-1 + 1 );
For API Program Development Impact:

When JSON is provided to the app and browser JS engines through PHP APIs, the int range of Android, IOS, and browser JS is inconsistent because PHP Web server is 64-bit.

The 32-bit int value is about 2.1 billion. For example, if the total user capacity of the network disk is 5 gib, the PHP interface returns the following data:

{

"Capacity": 5368709120, // capacity: 5.3 billion bytes, that is, 5 gib, over 2.1 billion

"Used_space": 1073741824

}

Result: The Android Java app is normal, the iOS app cannot process data, and the browser Javascript is normal.

Therefore, you need to use a string instead of an int. After IOS receives the result, it is necessary to split the integers. That is:

{

"Capacity": "5368709120 ",

"Used_space": "1073741824"

}

References:

Http://www.cnblogs.com/sink_cup/archive/2010/12/12/php_intval_mysql_int.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.