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

  • Home
  • SEARCH
  • 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 6725983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:52:20+00:00 2026-05-26T09:52:20+00:00

I have a small question which is confusing me, I have a variable of

  • 0

I have a small question which is confusing me, I have a variable of type double named as RevisionRatio in which I am using this expression.

RevisionRatio = ((WriterRevisions/TotalRevisions) * 100) now lets consider that WriterRevisions = 5 and TotalRevisions = 11 so it makes ((5/11)*100) = 45.45% but for some reason it is giving me 0 all the time, I know I am doing some small mistake and I can’t seem to find it on google, your help is greatly appreciated, this is my code.

    protected void MyMonthlyRevisionRatio(bool DateSpecified)
{
    int TotalRevisions = 0;
    int WriterRevisions = 0;
    double RevisionRatio = 0;
    using (LogiConnection = new SqlConnection(CIPConnection))
    {
        LogiConnection.Open();
        DateTime DT = DateTime.Now;
        using (LogiCommand = new SqlCommand(Functions.NewString("SELECT COUNT(DISTINCT LCR.revision_id) AS revisions FROM LogiCpsRevisions AS LCR INNER JOIN LogiCpsLogs AS LCL ON LCL.project_id = LCR.project_id WHERE (DATENAME(mm, GETDATE()) = DATENAME(mm, LCL.creation_date))"), LogiConnection))
        {
            LogiCommand.Parameters.AddWithValue("@writer_id", HFSqlParameters.Value);
            TotalRevisions = Convert.ToInt16(Functions.GetResults(LogiCommand)[0]);
        }
        if (DateSpecified)
        {
            using (LogiCommand = new SqlCommand(Functions.NewString("SELECT COUNT(DISTINCT LCR.revision_id) AS revisions FROM LogiCpsRevisions AS LCR INNER JOIN LogiCpsLogs AS LCL ON LCL.project_id = LCR.project_id WHERE (LCL.writer_id = @writer_id) AND (DATENAME(mm, GETDATE()) = DATENAME(mm, LCL.creation_date)) AND (creation_date BETWEEN @FromDate AND @ToDate)"), LogiConnection))
            {
                LogiCommand.Parameters.AddWithValue("@writer_id", HFSqlParameters.Value);
                LogiCommand.Parameters.AddWithValue("@FromDate", FromDtPicker.SelectedDate);
                LogiCommand.Parameters.AddWithValue("@ToDate", ToDtPicker.SelectedDate);
                WriterRevisions = Convert.ToInt16(Functions.GetResults(LogiCommand)[0]);
                RevisionRatio = ((WriterRevisions / TotalRevisions) * 100);
                lblMyRevisionRatio.Text = "7. Revision ratio : " + RevisionRatio + "in the given period.";
            }
        }
        else
        {
            using (LogiCommand = new SqlCommand(Functions.NewString("SELECT COUNT(DISTINCT LCR.revision_id) AS revisions FROM LogiCpsRevisions AS LCR INNER JOIN LogiCpsLogs AS LCL ON LCL.project_id = LCR.project_id WHERE (LCL.writer_id = @writer_id) AND (DATENAME(mm, GETDATE()) = DATENAME(mm, LCL.creation_date))"), LogiConnection))
            {
                LogiCommand.Parameters.AddWithValue("@writer_id", HFSqlParameters.Value);
                WriterRevisions = Convert.ToInt16(Functions.GetResults(LogiCommand)[0]);
                RevisionRatio = ((WriterRevisions / TotalRevisions) * 100);
                //Response.Write(TotalRevisions);
                //Response.Write(WriterRevisions);
                //Response.Write(RevisionRatio.ToString());
                lblMyRevisionRatio.Text = "7. Revision ratio : " + RevisionRatio + " in the month of " + DT.ToString("MMMM") + ".";
            }
        }
    }
}

Thanks.

  • 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-26T09:52:21+00:00Added an answer on May 26, 2026 at 9:52 am

    Change

    int TotalRevisions = 0;     
    int WriterRevisions = 0; 
    

    to

    double TotalRevisions = 0;     
    double WriterRevisions = 0; 
    

    integer division returns an integer – 0.4545 gets truncated and rounded down to 0

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

Sidebar

Related Questions

I'm using BerkeleyDB to develop a small app. And I have a question about
I have a simple small question which someone who knows will be able to
I have a small question regarding rails. I have a search controller which searches
I have a setup as described in this question which works perfectly. Essentially a
I have a small question. How can I test an application which uses the
This is a continuation to this question which Oleg has answered. I have 2
I have a small question. A module which I am working at the moment
I have an small question I didn't found an answer yet: how do I
I'm not much into COM interfaces, so i have a small question, say I
Just a small question regarding joins. I have a table with around 30 fields

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.