Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6676177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:57:16+00:00 2026-05-26T03:57:16+00:00

I am using MySQL C API. Now I have some Double Typed data in

  • 0

I am using MySQL C API.
Now I have some Double Typed data in C, and I want to insert them to a database.
All I know now is to use mysql_real_query() with a statement string to do this.
I am worrying about losing precision, since the process above involves double to string then to double. Is there a way to avoid this? Like sending double binary data directly to MySQL? I assume MySQL implements double the same as C does.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:57:16+00:00Added an answer on May 26, 2026 at 3:57 am

    You should use a prepared statement with a placeholder for your double and then you can bind a double without converting anything to a string. Something like this:

    char *insert = "insert into pancakes (d) values (?)";
    MYSQL_BIND b;
    MYSQL_STMT *stmt = mysql_stmt_init(mysql);
    mysql_stmt_prepare(stmt, insert, strlen(insert));
    
    b.buffer_type = MYSQL_TYPE_DOUBLE;
    b.buffer = &your_double;
    /* Fill in the rest of b...*/
    mysql_stmt_bind_param(stmt, &b);
    

    References:

    • mysql_stmt_init
    • mysql_stmt_prepare
    • Type Codes
    • mysql_stmt_bind_param
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Mysql c api for database interaction, I want to know that
I have been using the mysql api in PHP, and am now converting to
I am using the MySQL C API within a C++ application. I have a
I'm using MySQL API's function mysql_real_escape_string() Based on the documentation, it escapes the following
I am using mySQL from their C API, but that shouldn't be relevant. My
I'm writing a program using C++ and the MySQL C API (version 5.1.31 ubuntu2).
(Using MySQL and PHP) I have a search form that will allow my users
Using MySQL, I have three tables: projects : ID name 1 birthday party 2
I have a project (#1) with a couple apps in it using a mysql
I am creating a scheduler using PHP/MySQL where I have to allow the use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.