php-sqllite-php binary Double-precision floating point data stored in SQLlite3, the result is not correct, how?

Source: Internet
Author: User
Keywords php-sqllite php
1. Recently doing some sqlite3 things, defined a blob type of field, want to put double-precision floating point in here, so the strange thing happened. Double precision floating point number 13.46, hex 402A EB85 1eb8 51EC, but sqlite inside data is 402A CB85 1ec2 B851 efbf BD, this tm what ghost, code as follows:

$str=$common->DoubleToHex(13.46);$s=hex2bin($str);echo $str;//输出的结果是402A EB85 1EB8 51EC,这是正确的$data->InsertData("table01", "'SS','0','".$s."'","time,timespan,data");//把数据插入到sqlite里面,数据就不对了

Strangely, the error occurs only when the double is created, and the other data formats are no problem.

Reply content:

1. Recently doing some sqlite3 things, defined a blob type of field, want to put double-precision floating point in here, so the strange thing happened. Double precision floating point number 13.46, hex 402A EB85 1eb8 51EC, but sqlite inside data is 402A CB85 1ec2 B851 efbf BD, this tm what ghost, code as follows:

$str=$common->DoubleToHex(13.46);$s=hex2bin($str);echo $str;//输出的结果是402A EB85 1EB8 51EC,这是正确的$data->InsertData("table01", "'SS','0','".$s."'","time,timespan,data");//把数据插入到sqlite里面,数据就不对了

Strangely, the error occurs only when the double is created, and the other data formats are no problem.

  • 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.