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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:26:27+00:00 2026-06-18T08:26:27+00:00

I have SQL table with a column with a data type of Float. There

  • 0

I have SQL table with a column with a data type of Float. There is an external app that writes percentage values to this column and I read them and display them in a web app.

I understand how to convert decimal’s to percentages; usually I would multiply by 100, but this is a little different.

The values in the DB look like this:

 0.95  <-- DB  5%  <-- UI
 0.85  <-- DB  15% <-- UI
 0.5   <-- DB  50% <-- UI

I have tried

number * percentage / 100

and

((percentage /100) * value).ToString();

and

 string percentage = string.Format("Percentage is {0:0.0%}", value);

and

 percentage/100m*value

and

 myDecimal.ToString("0.00");

and finally, what I thought was close:

Math.Round(myDecimal, 2).ToString("{0.00}");

and of course various string formatting things like

 MyDecimal.ToString("P"), .ToString("P1"), etc)

Articles on Formatting, Rounding and Converting Percentages in C#:

Convert percentage to nearest fraction,
Working percentage in c#,
http://www.dotnetperls.com/percentage,

But I can not for the life of me find a math calculation or built in c# conversion to give me the output I need.

What it seems like I need to do is get the 0.96 digits to be subtracted by some number and then in turn multiply that by 100, but the 0.5 being 50% always throws my math off….

This seems like it would be a common conversion; what I am missing here?

UPDATE

Here is a the solution I ended up with, which works great! (Thanks Reed)

            var li = new List<Object>();
        var retVal = new List<string>();

        li.Add(.5);       // 50%
        li.Add(.95);      // 95%
        li.Add(.85);      // 85%
        li.Add(0.87813);  // 12.18700%

        foreach (var o in li)
        {
            var value = Convert.ToDouble(o);
            string percentage = string.Format("Percentage is {0:0.0%}", 1.0 - value);

            retVal.Add(percentage);
        }

LINKS

For the sake of completeness, here is a pretty consise list of resources on Decimals, Percentages, Doubles, and conversions in C#:

A+

Working percentage in c#
Format decimal for percentage values?
Convert percentage to nearest fraction
http://www.dotnetperls.com/percentage
.NET: Decimal to rounded string
C# Is there a built-in function to convert a formatted String back to a Number?

A-

Format decimal as a percent with specific decimal places
Convert decimal to percent or shift decimal places. How
How to convert percentage string to double?

B+

two ways of displaying a decimal
http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx

  • 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-06-18T08:26:28+00:00Added an answer on June 18, 2026 at 8:26 am

    I believe you’d want:

    string percentage = string.Format("Percentage is {0:0.0%}", 1.0 - value);
    

    If you just want the number:

    string percentage = (1.0 - value).ToString("P");
    

    Or, the number without decimal precision:

    string percentage = (1.0 - value).ToString("P0");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table with a column that needs the data type upgrading. However
I have a SQL stored procedure that returns a column value (SQL data type:
I have one table that has Image Data type column, that column contains Pdf
I have a table that contains a GEOMETRY data type. SQL Server 2008 ships
In a table column, I have this value: DV-2011-01-000004 (the data type is varchar2)
I have some data in an SQL table with an XML datatype column where
If i have a sql table with column like this id version subversion 1
I have a value in my MS SQL table column called XDATA like this:
I have an SQL Server 2008 database with a table that has a column
I have a table, which contains many columns of float data type with 15

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.