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 4231012
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T01:55:27+00:00 2026-05-21T01:55:27+00:00

I have a large value in MySQL. It is stored in MySQL properly as

  • 0

I have a large value in MySQL. It is stored in MySQL properly as a DECIMAL(22,2). I have confirmed that the value is stored properly. If I run a query via command console I get the proper value back in the desired non-scientific form (the value and the form is: 99996543210987654321.99).

The problem is that when I run the query with Qt/C++ I don’t see how I can show the number in non-scientic notation. I get (9.99965432109877e+19) instead of (99996543210987654321.99). I want the later.

In C++/Qt This is how I extract the value from the Qt query.
(1) First, I open a database connection to MySQL with Qt.
(2) Then, I make a query to find a specific record. So far so good.
(3) Then, I extract the specific field value from the returned record found by the query using the exact code posted bellow.
*NOTE. QSqlQuery::value returns a Qvariant.
http://doc.qt.io/qt-5/qvariant.html#QVariant-30

if( query3.next() )
{
   QVariant number = query3.value(query3.record().indexOf("account_balance"));
   qout << number.toString() << endl;
}

I have also tried (with same result).

if( query3.next() )
{    
 qout<<query3.value(query3.record().indexOf("account_balance")).toString()<<endl;
}

Just to add, “qout” is just a QTextStream. I think the problem is not qout because the code bellow outputs 99996543210987654321.99 as is without scientific notation.

qout << "99996543210987654321.99" << endl;

How can I get back value 99996543210987654321.99 as is without rounding by c++/qt and without scientific notation?

.
.
.
.
.
.


EDIT:
tried at Pete’s suggestion

char string_account_balance[32] = "";
sprintf( string_account_balance, "%.2f", query3.value(query3.record().indexOf("account_balance")).toString() );

Got errors and crash. Errors:
(1) connot pass objects of non-POD type ‘class QByteArray’ through ‘…’; call will abort runtime
(2) format ‘%.2f’ expects type ‘double’, but argument 3 has type ‘int’.

  • 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-21T01:55:28+00:00Added an answer on May 21, 2026 at 1:55 am

    QSqlQuery::value() returns a QVariant, and there is no QVariant::toLongDouble or anything like that (aside from toString(), which doesn’t work). So you have to do the conversion in MySQL–ALTER TABLE with the CHANGE option to change DECIMAL to VARCHAR or something like that, query the result, and then change it back. Otherwise, looks like you’re out of luck, esp. given the link MSalters posted.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm (attempting) to write a MySQL stored procedure that parses a large text file.
I have an large list of XML documents stored in MySQL (yes I know...)
i have a large mysql database table in which one column contains values ranging
I have large video files (~100GB) that are local on my machine. I have
I'm trying to create a faster query, right now i have large databases. My
i have a large MYSQL database with hundreds of thousands of records. i want
I often have large arrays, or large amounts of dynamic data in PHP that
I have a very large table in MySQL. I'm using a CHAR(32) field which
I have a fairly large mysql database and I would like to count all
I have the following code: $link = new PDO(mysql:dbname=$databasename;host=127.0.0.1,$username,$password); $query = $link->prepare(SELECT * FROM

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.