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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:15:20+00:00 2026-06-04T01:15:20+00:00

We are finding some strange behaviour with the decimals being displayed to the console.

  • 0

We are finding some strange behaviour with the decimals being displayed to the console.
This is best discribed by the following code:

string num1AsString = "1.0000";
decimal num1AsDecimal = decimal.Parse(num1AsString);

string num2AsString = "1";
decimal num2AsDecimal = decimal.Parse(num2AsString);

Console.WriteLine(num1AsDecimal);
Console.WriteLine(num2AsDecimal);

The output to the Console is:

1.0000
1

However num1AsDecimal and num2AsDecimal show up in the debugger as 1 only.
How is num1AsDecimal somehow preserving the .0000? It seems to be somehow holding onto its string representation. Is there some kind of boxing going on here?

Billy Stack

  • 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-04T01:15:21+00:00Added an answer on June 4, 2026 at 1:15 am

    We are finding some strange behaviour with the decimals being displayed to the console.

    It’s not strange at all. It’s documented:

    The scaling factor also preserves any trailing zeroes in a Decimal number. Trailing zeroes do not affect the value of a Decimal number in arithmetic or comparison operations. However, trailing zeroes can be revealed by the ToString method if an appropriate format string is applied.

    In other words, it’s the debugger behaviour which is slightly strange here, not ToString(). In the debugger if you watch num1AsDecimal.ToString(), that should preserve the trailing zeroes too.

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

Sidebar

Related Questions

I am manually converting code from Java (1.6) to C# and finding some difficulty
I'm having some trouble with finding the visibility param for JQuery. Basically... the code
Strange situation: I am trying to remove some hard coding from my code. There
Can anyone help me in finding some code examples or tutorials to understand how
Finding some text and replacing it with new text within a C string can
I recently created my first Heroku application and I'm finding some strange behavior: When
This problem is very strange, maybe I have missed some small detail, since I'm
I'm finding some problems with a query that returns the sum of a field
I am using matplotlib and I'm finding some problems when trying to plot large
I've been playing with jQuery in an ASP.NET project and am finding some odd

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.