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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:50:39+00:00 2026-05-29T10:50:39+00:00

I retrieve numeric/decimal/money column values from SQL Server database as SQL_NUMERIC_STRUCT structures. Now I

  • 0

I retrieve numeric/decimal/money column values from SQL Server database as SQL_NUMERIC_STRUCT structures. Now I have to convert it to double for internal processing, and to string for GUI output. How can this be done?

  • 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-29T10:50:39+00:00Added an answer on May 29, 2026 at 10:50 am

    Here is a good start. It doesn’t convert everything that you want to convert, but you can use the idea and algorithm to do arbitrary conversion with some simple mods:

    DWORD g_Denominators[10]={1,10,100,1000,10000,100000,1000000,10000000,
                              100000000,1000000000};
    
    void FetchDecimalValue(Fraction::NumeratorType &numerator, 
                           Fraction::DenominatorType &denominator,
                           const SQL_NUMERIC_STRUCT &src)
    {
      numerator=0;
      denominator=1;
      DWORDLONG byteDenominator=1;
    
      for (size_t valIdx=0;valIdx<SQL_MAX_NUMERIC_LEN;++valIdx)
      {
        numerator+=src.val[valIdx]*byteDenominator;
        byteDenominator<<=8UI64;
      }
    
      // Is the NUMERIC negative?
      if (src.sign==0)
        numerator=-numerator;
    
      denominator=g_Denominators[src.scale];
    }
    

    You can easily create a double out of the resulting numerator and denominator by dividing the former by the later. Also, to create a string, you can always resort to sprintf or for a more C++ way, the double formatter of ostringstream.

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

Sidebar

Related Questions

Can a Linq query retrieve BLOBs from a Sql Database? And how do they
I retrieve information from my database and it is all in a Cursor. Now
I have a MySQL database with a column of numeric value. When I query
For the currency code ISO 4217, how do I retrieve the numeric value from
I retrieve .jpgs from my server and load them within my as3 app. I
I'm trying to retrieve a file from a server using SFTP (as opposed to
I need to convert the following stored procedure of SQL Server to MySQL. I
I'm having a problem with summing floats properly from my SQLite database. I have
I am trying to retrieve the largest number from a varchar column that includes
I have a routine that will be creating individual tables (Sql Server 2008) to

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.