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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:47:13+00:00 2026-05-20T12:47:13+00:00

How do I divide an int by 100? eg: int x = 32894; int

  • 0

How do I divide an int by 100?

eg:

int x = 32894;
int y = 32894 / 100;

Why does this result in y being 328 and not 328.94?

  • 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-20T12:47:13+00:00Added an answer on May 20, 2026 at 12:47 pm

    When one integer is divided by another, the arithmetic is performed as integer arithmetic.

    If you want it to be performed as float, double or decimal arithmetic, you need to cast one of the values appropriately. For example:

    decimal y = ((decimal) x) / 100;
    

    Note that I’ve changed the type of y as well – it doesn’t make sense to perform decimal arithmetic but then store the result in an int. The int can’t possibly store 328.94.

    You only need to force one of the values to the right type, as then the other will be promoted to the same type – there’s no operator defined for dividing a decimal by an integer, for example. If you’re performing arithmetic using several values, you might want to force all of them to the desired type just for clarity – it would be unfortunate for one operation to be performed using integer arithmetic, and another using double arithmetic, when you’d expected both to be in double.

    If you’re using literals, you can just use a suffix to indicate the type instead:

    decimal a = x / 100m; // Use decimal arithmetic due to the "m"
    double b = x / 100.0; // Use double arithmetic due to the ".0"
    double c = x / 100d; // Use double arithmetic due to the "d"
    double d = x / 100f; // Use float arithmetic due to the "f"
    

    As for whether you should be using decimal, double or float, that depends on what you’re trying to do. Read my articles on decimal floating point and binary floating point. Usually double is appropriate if you’re dealing with “natural” quantities such as height and weight, where any value will really be an approximation; decimal is appropriate with artificial quantities such as money, which are typically represented exactly as decimal values to start with.

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

Sidebar

Related Questions

In c# how do I evenly divide 100 into 7? So the result would
The following code does not catch an exception, when I try to divide by
Consider the following signature in C#: double Divide(int numerator, int denominator); Is there a
This may be a matter of style, but there's a bit of a divide
I have two integers that I want to divide to get a percentage. This
I am trying to divide integers but get 0 as result. I just do
All numbers that divide evenly into x. I put in 4 it returns: 4,
What is the best way to divide a 32 bit integer into four (unsigned)
There appears to be some debate about the divide is between wanting an SDK
I have a program which deliberately performs a divide by zero (and stores the

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.