Php-sqllite-php stores binary double-precision floating point data in SQLlite3. The result is incorrect. Why?

Source: Internet
Author: User
1. Recently I have made some sqlite3 tasks, defining a blob-type field and saving double-precision floating point numbers here, so something strange happened. The double-precision floating point number is 13.46. The hexadecimal value is 402AEB851EB851EC, but the data in SQLITE is 402ACB851EC2... 1. recently, I have made some sqlite3 tasks. I have defined a blob field and want to store the double-precision floating point number here. This is a strange thing. Double-precision floating point number 13.46. The hexadecimal value is 402A EB85 1EB8 51EC. However, the data in SQLITE is 402A CB85 1EC2 B851 efbf bd. What is this TM? The Code is as follows:

$ Str = $ common-> DoubleToHex (13.46); $ s = hex2bin ($ str); echo $ str; // The output result is 402A EB85 1EB8 51EC, this is correct $ data-> InsertData ("table01", "'ss', '0 ','". $ s. "'", "time, timespan, data"); // Insert the data into sqlite. The data is incorrect.

The strange thing is that errors are generated only when they are double, and other data formats are okay.

Reply content:

1. Recently I have made some sqlite3 tasks, defining a blob-type field and saving double-precision floating point numbers here, so something strange happened. Double-precision floating point number 13.46. The hexadecimal value is 402A EB85 1EB8 51EC. However, the data in SQLITE is 402A CB85 1EC2 B851 efbf bd. What is this TM? The Code is as follows:

$ Str = $ common-> DoubleToHex (13.46); $ s = hex2bin ($ str); echo $ str; // The output result is 402A EB85 1EB8 51EC, this is correct $ data-> InsertData ("table01", "'ss', '0 ','". $ s. "'", "time, timespan, data"); // Insert the data into sqlite. The data is incorrect.

The strange thing is that errors are generated only when they are double, and other data formats are okay.

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.